Open In App

How to solve npm error npm ERR! code ELIFECYCLE ?

Last Updated : 19 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In order to solve the “npm ERR! code ELIFECYCLE ” error which is a very common type of error that occurs during npm operation on our command prompt or terminal such as installing npm or an npm package, follow the steps given below : 

Terminal output of the error :

Follow below steps to fix the error :

Step 1 : In our first step we will try cleaning the cache of the npm which is installed in the project directory .npm stores cache data in an opaque directory within the configured cache, named _cacache

The npm stores the cache data in a hidden directory within the configured cache , and the name of that cache is _cacache. The “_cacache” stands for Content addressable cache that stores all the HTTP request data as well as other package related data.

$ npm cache clean –force

Step 2 (Delete node_modules) : In our second step we will delete the node_modules folder which will be structured in this manner in your project directory .

Just hover your cursor to the node_modules folder and right click on it and choose “delete” from the option displayed . This operation should delete your node_modules folder from the project structure .

Step 3 (Delete package-lock.json ): Similar to the second step we will now delete the “package-lock.json” file from the project directory as well .But this “package-lock.json”  may appear again in the project directory as we are going to perform “$ npm install ” again in the next step .

Step 4 : In this step we must again install npm into our project directory as we have deleted the node_modules folder in the second step which removes npm that was installed in the project. Therefore, to install the npm again in the project directory use the following command.

$ npm install 

This will resolve the conflicts/errors. Kindly make sure that npm is installed properly, and you have got your node_modules folder again at the same location.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads