How to solve npm ERR! code ELIFCYLCE


Yesterday my clients shared a git repository to me, consist of a web projects built with Next.js. He asked me to do some modification and add new feature to the project.

Long story short, I’ve clone the project into my local environment and when I tried to run the projects locally, with npm install, npm run dev command, surprisingly this error appear:

Error ELIFCYCLE when running npm run dev command

My first assumption is, “oh maybe just update the npm package with ‘npm update’ command and everything should be OK!”

But, it doesn’t work at all! The issue are still there. So after do some research, apparently the issues caused by outdated react-scripts. I try to do these steps:

  1. Remove node_modulesrm -rf node_modules
  2. Remove package-lock.jsonrm package-lock.json
  3. Run command → npm i -s — save-exact react-scripts@desired_version where the desired_version is the latest version
  4. Run npm install again
  5. Run npm run dev

And sometimes it works, but sometimes the error suddenly appear again ☹️

So I decide to change the build command, from npm to yarn. Probably it will works 🤷‍♂️

  1. Remove node_modules
  2. Remove package-lock.json
  3. Run yarn install
  4. Run yarn upgrade --latest react-scripts
  5. Run yarn upgrade --latest (optional)
  6. Run yarn dev

and voila 🎊 it works!!!

Now the Next.js project can run smoothly on my localhost! I hope this solution will work for you also, in case you are facing the same issues.

or if you have a better approach, please do let me know 🙂

Email icon representing an email newsletter

Don't subscribe