How to solve npm error "npm ERR! code ELIFECYCLE"
Asked Answered
C

50

500

I'm trying to learn react, so I have this sample code for the full-stack react voting app, and I am trying to get it to work but after running npm install followed by npm start I receive the following error when I run npm start can anyone help me with this issue:

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "server"
npm ERR! node v7.5.0
npm ERR! npm  v4.3.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] server: `live-server --public --    
host=localhost --port=3000 --middleware=./disable-browser-cache.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] server script 'live-server --
public --host=localhost --port=3000 --middleware=./disable-browser- 
cache.js'.
npm ERR! Make sure you have the latest version of node.js and npm  
installed.
npm ERR! If you do, this is most likely a problem with the voting_app  
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     live-server --public --host=localhost --port=3000 --  
middleware=./disable-browser-cache.js
npm ERR! You can get information on how to open an issue for this  
project with:
npm ERR!     npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls voting_app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_581Z-
debug.log

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.5.0
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `npm run server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'npm run server'.
npm ERR! Make sure you have the latest version of node.js and npm 
installed.
npm ERR! If you do, this is most likely a problem with the voting_app    
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run server

npm ERR! You can get information on how to open an issue for this   
project with:
npm ERR!     npm bugs voting_app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls voting_app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/ItsMeMrLi/.npm/_logs/2017-02-17T22_48_03_655Z-
debug.log

Here is my package.json:

{
  "name": "voting_app",
  "version": "1.1.0",
  "author": "Fullstack.io",
  "scripts": {
    "go": "open http://localhost:3000; npm run server",
    "e2e": "nightwatch",
    "test": "./node_modules/.bin/concurrently -k 'npm run server' 'npm  
run e2e'",
    "start": "npm run server",
    "server": "live-server public --host=localhost --port=3000 --  
middleware=./disable-browser-cache.js"
  },
  "private": true,
  "devDependencies": {
  "concurrently": "2.2.0",
  "live-server": "git://github.com/acco/live-server.git"
},
  "dependencies": {
  "semantic-ui": "git://github.com/Semantic-Org/Semantic-
  UI.git#27d58a01793b66318478fbc5b6676804d22d065d"
  }
}

And finally my log file:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 silly lifecycle [email protected]~prestart: no script for prestart, continuing
7 info lifecycle [email protected]~start: [email protected]
8 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1/bin:/Users/ItsMeMrLi/.rvm/gems/ruby-2.3.1@global/bin:/Users/ItsMeMrLi/.rvm/rubies/ruby-2.3.1/bin:/Users/ItsMeMrLi/.cargo/bin:/usr/local/Cellar/smlnj/110.74/libexec/bin:/usr/local/bin:/Users/ItsMeMrLi/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Downloads/geckodriver:/usr/local/bin:/Users/ItsMeMrLi/.rvm/bin
10 verbose lifecycle [email protected]~start: CWD: /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
11 silly lifecycle [email protected]~start: Args: [ '-c', 'npm run server' ]
12 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: `npm run server`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:192:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:192:7)
14 verbose stack     at maybeClose (internal/child_process.js:890:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /Users/ItsMeMrLi/Downloads/fullstack-react-code/voting_app
17 error Darwin 16.4.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.5.0
20 error npm  v4.3.0
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] start: `npm run server`
23 error Exit status 1
24 error Failed at the [email protected] start script 'npm run server'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the voting_app package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error     npm run server
24 error You can get information on how to open an issue for this project with:
24 error     npm bugs voting_app
24 error Or if that isn't available, you can get their info via:
24 error     npm owner ls voting_app
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]
Copyboy answered 17/2, 2017 at 23:2 Comment(2)
Make sure you also have space left on the drive.Decentralize
If you were like me you were following the FullStack React book. When you posted this question it is very likely you omitted the vital part of the message preceding what you posted. See here https://mcmap.net/q/53629/-how-do-i-resolve-quot-cannot-find-module-quot-error-using-node-js (relative path of disable-browser-cache.js). ./ -> ../.. github.com/tapio/live-server/issues/245Heal
I
553

Step 1: $ npm cache clean --force

Step 2: Delete node_modules by $ rm -rf node_modules (rmdir /S /Q node_modules in windows) folder or delete it manually by going into the directory and right-click > delete / move to trash. If you are not updating your packages you can delete the package-lock.json file too.

Step 3: npm install

To start again, $ npm start

This worked for me. Hope it works for you too.

While above suggests re-creating package-lock.json file, ensure package-lock.json file exists to begin with, and is tracked by VCS/Git (if the project has VCS).

PS: Still if it's still there, kindly check the error it is displaying in red and act accordingly. This error is specific to node.js environment.

Irksome answered 27/3, 2018 at 6:19 Comment(7)
heads up be careful when using rm -rfNucleotide
For Step 2 in Windows you can do rd /s /q "node_modules"in cmd or rm -r "node_modules" in PowerShell SourceEdda
In my case deleting node_modules helped, but this folder that was one level up to the project. npm cache clean --force was causing weird behavior instead and was misleading. Before I deleted this directory I also deleted local repository for this project and cloned it again, not sure if it was helping though since the action I described solved the situation finally.Bedim
If that doesn't work, you can always command another npx create-react-app spare, and copy node_modules over to project appropriately.(USER FRIENDLY WAY)Gussie
It's worth mentioning that in many instances it is not recommended to delete package-lock.json because of dependency version rollbacks. See a similar answer by skyboyer to a similar question. Using the above advice has created a considerable mess for me, thank you for answering in any case! #54124533Fulminate
for step 2, I think you can use npm ciPyridoxine
For step 2 another option is npx rimraf node_modulesSarnoff
R
166

Cleaning Cache and Node_module are not enough. Follow this steps:

  • npm cache clean --force
  • delete node_modules folder
  • delete package-lock.json file
  • npm install

It works for me like this.

Rilke answered 31/8, 2018 at 21:2 Comment(7)
Fixed for me using npm cache verify instead of deleting the entire cache.Treece
I think the most important thing is delete the package-lock.json file, before try this, I've tried many ways all cannot fix the error.Pulsatile
The fact that you can fix ANYTHING by simply deleting an autogenerated build artifact is everything that is wrong with the JS universe... If it wasn't for this stackoverflow entry I would have been S.O.L. here as there was no actionable error I could discern in the build log!Ludmilla
Most imp is deleting package-lock.jsonRincon
If the error still exist after the above solutions, increase the no of listeners. github.com/guard/listen/wiki/…Adverbial
@Treece did npm cache verify replace all 4 steps, or just the first?Oleograph
Do not modify package-lock.json file manually. Delete it instead and run npm update. This can cause problems.Ordination
S
44

I resolve this error running following code

npm cache clean

then delete node_modules directory from my project structure manually or with following command

rm -rf node_modules

After That install dependencies again using

npm install
Stauffer answered 27/3, 2017 at 5:50 Comment(5)
It would really help if you can elaborate the answer for the beginners like me. Brevity is good but doesn't help always. Thank you.Rhiamon
npm run clean is no command. But, still you idea worked. I deleted and reinstalled..and booom... it started working.. thanksBernice
Just the last instruction "npm install" worked in my similar case.Latex
had that problem with Nuxt.js after copy / paste my code from desktop to server. not it works thanksPhotogram
npm cache clean then npm cache verify then rm -rf node_modules then npm installReduce
H
34

first i ran:

npm run clean

(even though it came with errors)

Then i deleted the node_modules folder and ran

npm install

This seems to have solved the problem.

Hypotaxis answered 30/9, 2017 at 6:26 Comment(1)
npm ERR! missing script: cleanHawkinson
I
33

I was getting similar error messages on a 16.04 Ubuntu instance with DigitalOcean while running npm run build on an app made with create-react-app (link). I upgraded the instance from 512MB RAM to 1GB ($5/mo to $10/mo) and then the script was able to run.

I post this here to point out that you may get this error due to resource limitations, which I didn't really see explained elsewhere on issue pages and SO answers. And nothing I saw in the error logs pointed me in this direction.

Impotent answered 6/11, 2017 at 18:32 Comment(3)
You are completely right ! Nothing point me in this direction too, and it was a bug due to resource limitations... TySabbath
Yeah I was getting similar issue compiling Laravel-mix on EC2 t3a.nano instance. Seems to be lack of memory. Resolved on a larger instance.Mastat
Before you do this, you might want to try to reboot your server first: digitalocean.com/community/questions/… For me that was sufficient already :)Beadledom
S
23

Change access in node_modules directory

chmod -R a+rwx ./node_modules 
Servia answered 3/9, 2017 at 2:53 Comment(0)
C
20

This solution is for Windows users.

You can open the node.js installer and give the installer some time to compute space requirements and then click next and click remove. This will remove node.js from your computer and again reopen the installer and install it in this path - C:\Windows\System32

or

Cleaning Cache and Node_module will work. Follow this steps:

  • npm cache clean --force
  • delete node_modules folder
  • delete package-lock.json file
  • npm install
Christiano answered 29/7, 2020 at 12:31 Comment(3)
Recently I updated my node on windows to 12.X.X, I see the same errors, Cleaning the cache didn't help. Any other possible solutions?Confide
@Confide Did you try reinstalling in the node path mentioned in my answer.Christiano
@Confide the purpose for the first fix was not to update it was to reinstall in the path C:\Windows\System32Christiano
C
13

Faced this exact problem,

for me it worked by deleting package-lock.json and re-running npm install

If that doesn't resolve it try

  1. delete package-lock.json
  2. npm cache clean --force
  3. npm install
  4. npm start
Convent answered 9/4, 2019 at 14:17 Comment(0)
A
11

Delete node_modules and package-lock.json, and then run npm install. It worked perfectly here(run command below inside project root):

rm -rf node_modules && rm ./package-lock.json && npm install
Antlia answered 19/6, 2018 at 19:1 Comment(0)
S
11

I was getting this npm ERR! code ELIFECYCLE error while running a build. Clearing the cache and removing the package-lock.json files did not fix it.

In my case there was an Angular build running on a Docker image that was causing this. The root cause turned out to be running the build on Docker in MacOS, which runs the Docker inside a Linux VM, and has by default 2GB memory allocated.

Giving Docker more memory fixed this issue for me. Have to say, the error message could have been quite a bit more clear..

A helpful answer for me was Call retries were exceeded exception while ng build

Stereoscopic answered 4/9, 2020 at 10:35 Comment(0)
R
6

workaround: Remove the lock file.

rm .\package-lock.json

source: https://github.com/mapbox/node-pre-gyp/issues/298 (floriantraber)

Ramberg answered 14/7, 2017 at 10:19 Comment(0)
C
6

React Application: For me the issue was that after running npm install had some errors.

I've went with the recommendation npm audit fix. This operation broke my package.json and package-lock.json (changed version of packages and and structure of .json).

THE FIX WAS:

  • Delete node_modules
  • Run npm install
  • npm start

Hope this will be helpfull for someone.

Chloro answered 12/12, 2019 at 11:53 Comment(0)
P
5
npm install --unsafe-perm

worked for me. See https://docs.npmjs.com/. The --unsafe-perm parameter lets you run the scripts from the package instalation as root. The problem in my case was that some depandencies failed to install.

Pair answered 9/2, 2019 at 19:18 Comment(1)
Thanks, I had a problem with "node-pre-gyp", the "--unsafe-perm" solved my installation problem.Inwrap
D
5

This solution fixed the error in Win10.

Please install globally npm install -g node-pre-gyp

Dibucaine answered 8/5, 2019 at 3:59 Comment(1)
Please explain in more detail why you believe this is the solution. Also, give some consideration to others and give a description of what node-pre-gyp is and why this is the answer on Windows 10.Volsung
C
5

i tried to solve this problem with this way

rm -rf node_modules && rm ./package-lock.json && npm install

But for me its not work. I just restart my machine and its working perfectly.
Am Linux user ,Machine HP.

Cf answered 29/2, 2020 at 20:39 Comment(1)
I was using an Hp running windows and wsl and this worked for meInkhorn
F
5

I just wanted to do run npm run dist to apply some changes for SCSS files, but after hours of suffering, here's what worked for me:

  1. npm cache clean --force
  2. delete node_modules folder
  3. delete package-lock.json file
  4. sudo npm install npm@latest -g this will upgrade npm to latest version
  5. npm audit fix --force
  6. npm upgrade --force
  7. npm install

After these I could finally compile SCSS files successfully with npm run dist.

Furrow answered 2/9, 2021 at 13:28 Comment(0)
M
4

A possibly unexpected cause: you use Create React App with some warnings left unfixed, and the project fails on CI (e.g. GitLab CI/CD):

Treating warnings as errors because process.env.CI = true.
[ ... some warnings here ...]
npm ERR! code ELIFECYCLE
npm ERR! errno 1

Solution: fix yo' warnings!

Alternative: use CI=false npm run build

See CRA issue #3657

(Ashamed to admit that it just happened to me; did not see it until a colleague pointed it out. Thanks Pascal!)

Mortimer answered 4/11, 2019 at 21:53 Comment(0)
R
4

I recommend you update your node version to the latest node version recommended by your application or for short update your node version. I encountered this same problem using node version 11.1 but my application was recommending atleast version 10.x.x or 12.x.x I tried all the suggested reply on this thread but non seemed to work for me untill only when i updated my node version to the recommended latest version .i.e. version 12.16.3 then my application ran. enter image description here

Rarotonga answered 26/5, 2020 at 3:50 Comment(1)
Updating npm from 6.14.11 to 8.5.0 fixed the problem in my case although it now reports new ones :)Apiculture
V
4

In my case, I actually ran into this error "code ELIFECYCLE" in a Jenkins job. I tried to clean npm cache but it didn't work and also checked the memory of the Jenkins build server which looks okay. Then, I found the compiling of the react project actually failed in Jenkins but not in my local or when manually running the build on the Jenkins build server, and Jenkins also mentioned "Treating warnings as errors because process.env.CI = true". It looks like the warnings in my project cause the error on Jenkins. Therefore, I changed CI to true in the Jenkins job for now. That actually fixed the build error of Jenkins before I cleared those warnings.

Vulture answered 5/10, 2021 at 17:38 Comment(0)
S
3

Check for port availability as well if you encounter below message :

Error: listen EACCES 127.0.0.1:8080

at Object._errnoException (util.js:999:13)
at _exceptionWithHostPort (util.js:1020:20)
at Server.setupListenHandle [as _listen2] (net.js:1362:19)
at listenInCluster (net.js:1420:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1535:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:102:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
Staffordshire answered 1/1, 2018 at 6:46 Comment(1)
For me it was the port that was not available. All I had to do was change the port number and it worked.Basketwork
A
3

I'm using ubuntu 18.04 LTS release and I faced the same problem I tried to clean cache as above suggestions but it didn't work for me. However, I found another solution.

echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches

npm start

I run this command and it started to work

Amadus answered 4/7, 2020 at 10:21 Comment(0)
B
2

Try to reinstall the cli package globally. In my case, I was trying to test a Vue.js tutorial when I get the same error message. The other thing I did was run the vue command again but this time using webpack-simple and that is why I am not sure wich one solved the problem but now it is working.

Barneybarnhart answered 11/9, 2017 at 4:38 Comment(0)
M
2

I've been bothered by this issue for a long time. For me, the version of node was the problem.

My npm and node were 6.1.0 and 8.11.3, respectively. However, I didn't realize that I had updated my node accidentally to 12.*.*.

It then began to install GCX stuff whenever npm i, which was unnecessary before.

I downgraded my node to 8 and it worked!

Mease answered 7/8, 2019 at 16:32 Comment(0)
G
2

The port is probably being used by another application, try listing and see if it's your application:

lsof -i:8080

You can kill the process of this port:

lsof -ti:8080 | xargs kill

Gatha answered 6/9, 2019 at 11:4 Comment(0)
A
2

I did follow steps, it works:

1.

npm cache clean --force
  1. remove the package-lock.json file

  2. restart my WebStorm

Amii answered 27/9, 2019 at 9:22 Comment(0)
E
2

Usually killall node command fixes mine.

Expostulatory answered 15/8, 2020 at 3:8 Comment(4)
This is a comment more than an answer.Schober
Upvoted! This stops all instances of node servers and processes.Nitrochloroform
You forgot to mention that that's a MacOS command. (https://mcmap.net/q/56120/-stop-all-instances-of-node-js-server)[https://stackoverflow.com/…Insanitary
Also can be that webpack is still running from previous launch. So killall webpack also can help.Illness
B
1

Resolved like this:

# chown -R <user>: node_modules
Barlow answered 22/5, 2018 at 10:4 Comment(0)
S
1

In my case, I had checked out a different branch with a new library on it. I fixed my issue by only running npm install without doing anything else. I was confused why I was getting ELIFECYCLE error when the port was not being used, but it must have been because I did not have the library installed. So, you might not have to delete node_modules to fix the issue.

Samualsamuel answered 27/8, 2018 at 18:14 Comment(0)
Z
1

Make sure to use the latest npm version while installing packages using npm.

While installing JavaScript, mention the latest version of NodeJS. For example, while installing JavaScript using devtools, use the below code:

devtools i --javascript nodejs:10.15.1

This will download and install the mentioned NodeJS version. This worked for me.

Zacheryzack answered 6/6, 2019 at 15:39 Comment(0)
L
1

Its weird but it works for me

Go to

control panel -->System and Security--> System --> Advanced System Security--> Environment Variables

In Environment Variable popup you will edit the user variable PATH and add "C:\Windows\System32" value as semicolon separated to the existing value.

Not but not least restart the Machine.

enter image description here

Ludendorff answered 15/8, 2019 at 14:50 Comment(0)
C
1

I was issuing the npm start command with the folder of the project opened at Sublime Text. Closing ST and restarting the server did the work for me.

Colombia answered 12/11, 2019 at 12:22 Comment(0)
H
1

With cPanel on CentOS Linux (with PlanetHoster) NodeJS v10 is installed at /opt/cpanel/ea-nodejs10/bin which needs to be added to ~/.bash_profile :

PATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/cpanel/ea-nodejs10/bin

After that I had no problem with npm install

Higbee answered 18/6, 2021 at 8:20 Comment(0)
B
0

I am using react-create-app in Windows 10, on February 2nd, 2019 with latest NodeJS 11.9.0 and npm 6.7.0 (When you install NodeJS, the npm is existing). I think case of node packages are corrupted is rarely, the main cause permission.

At the beginning, I put project directory at Desktop, it is belong to C:\ driver. I move to another directory of another driver. Therefore, I remove "file permission" concern. Every work well and simple.

cd /d D:\
mkdir temp20190202
npx create-react-app my-app
cd my-app
npm start

It is ok, not put project folder in a directory of C:\ (or other driver what contains Windows Operating system).

Bionics answered 2/2, 2019 at 5:56 Comment(0)
E
0

I had the same issue with Angular 7. Just went through the following steps and error was solved.

1). Delete your node_modules folder and package-lock.json file.

2). Run npm install command.

3). Run npm audit fix command.

Exciting answered 4/5, 2019 at 6:17 Comment(0)
P
0

This had nothing to do with NPM packages for me. My Vuepress project was using a custom host name. Omitting this got things working again.

Pistoia answered 4/10, 2019 at 8:48 Comment(0)
L
0

This solved me on ubuntu 16

1) Update npm and node to latest version . 2) Restart System 3) Remove node_modules and again npm i & npm start

Lepidolite answered 3/12, 2019 at 10:45 Comment(0)
A
0

My situation called for removing webpack folder globally, then deleting project node_modules folder, package-lock.json and running npm install, npm start

Annulate answered 9/12, 2019 at 4:12 Comment(0)
I
0

The other answers did not solve the problem for my case. This works for me:

  • Try deleting your build output.
  • For me, that means deleting general.dll.js

Additional Details

  • Windows 10 64bit dev machine
  • NPM Start running webpack generating a build file: general.dll.js
  • If I get the ELIFECYCLE error upon "NPM Start" it is often after I have already successfully executed "NPM Start" but then stopped it, only to start "NPM Start" again.
  • I noticed that general.dll.js showed up in some of the hard-to-understand logs
Impassive answered 27/1, 2020 at 23:44 Comment(0)
G
0

My solution:

I was missing config.env properties because I was developing on a new machine, and of course I keep my config files out of my repo.

If you are using a different machine than usual, make sure that you include any config files that are not present in the repo that gets cloned.

Genuine answered 19/6, 2020 at 22:15 Comment(0)
C
0

In my instance the following worked:

I use node version manager on account of some projects running on older versions of Node.JS

Assure the project failing is running the correct Node version.

nvm use "correct node version"

npm install and npm start should do it.

Catherinacatherine answered 7/2, 2022 at 15:49 Comment(0)
C
0

ELIFECYCLE, from what I gather, basically means you are attempting to use packages that have reach their end-of-life. Update packages worked for me.

Try completely updating the newest, stable version of both nodejs and npm:

sudo apt -y update && sudo apt -y upgrade

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

sudo apt -y update && sudo apt -y upgrade
sudo apt -y autoremove

Then, change directories into your app directory:

cd myapp/ #Change this to match your app directory

Remove node_modules folder

sudo rm -rf node_modules/

Then reinstall the packages:

npm i

See if your app builds successfully:

npm run build
Confidence answered 22/3, 2022 at 20:6 Comment(0)
F
0

try this commands

1- update node

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

.

sudo apt-get install -y nodejs

2-remove node modules

 rm -rf node_modules/ package-lock.json

3-clear cache

npm cache clear --force

4-

npm install

if return notice to install new version ,run it, for example enter image description here

i run this command to update new version

npm install -g [email protected]

5-

 npm run dev
Ferule answered 13/11, 2022 at 20:51 Comment(0)
P
0
  1. You have to know exactly, which is your project node version, you can check it so:

    nvm ls

Depending on whether the project is old or new, node versions will differ, causing such problems. Then you will need to upgrade or downgrade your node version. In this way:

nvm install v14.0.0

And you have to use following version

nvm use v14.0.0

In my case, my project's node version was 14.0.0, and my node is 16.7.0, my solution

nvm install v14.0.0
nvm use v14.0.0

npm install
Predation answered 9/2, 2023 at 12:28 Comment(0)
M
0

Laravel9 v9.4.0 does not support Node.js < 16.0

You should upgrade Node.js version >= 16

Maul answered 13/2, 2023 at 11:30 Comment(0)
I
0

I am just on terminal type this line :

sudo npm link @angular/cli

and the boom Angular CLI: 15.2.7 Node: 18.16.0 Package Manager: npm 9.5.1 OS: darwin x64

Angular: undefined ...

Irwin answered 2/5, 2023 at 1:44 Comment(0)
W
0

adding package-lock=false to my .npmrc fixed this and seems to be equivalent (superficially) to the npm rm package-lock.json && npm cache clean --force && etc. Inspo.

Winner answered 6/3 at 7:8 Comment(0)
H
-1

Well! I got this error while writing react code many times, most of the time it is because of the following two

  1. When you imported something from the wrong library, for example
   import {Button} from "bootstrap"; //wrong one
   import {Button} from 'react-bootstrap';//the correct one
  1. When you imported two of the same name elements from different libraries
   import {Text} from 'react-native';
   import {Text} from 'native-base';

if this is not your mistake then you should delete all node modules and install again or start a new project and work on it!.

Homeo answered 26/3, 2021 at 7:20 Comment(0)
C
-1

This is an OOM issue in most cases and comes from a lack of available memory.

I managed to fix this after combining some of the recommendations here and elsewhere and I will detail them as someone may find them handy.

First of all, I will start by saying that I bought a very cheap VPS with 512 MB RAM to install Uptime Kuma and as per my review the available memory for node/npm was a little below 370 MB which was not enough to compile everything.

The VPS had no swap space so the process was getting killed due to OOM easily.

To fix this I created a 1 GB swap file and mounted it just as per the instructions here.

TL;DR, just execute these commands:

cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img    none    swap    sw    0    0" >> /etc/fstab

I did not need to do this step to prioritize swap over RAM, but you may need to so it is worth a try:

sysctl -w vm.swappiness=30

I will not bother you with details, they are all in the article.

Next I increased the max-old-space-size to 1024 by executing:

export NODE_OPTIONS="--max-old-space-size=1024"

As seen here. And then I ran npm successfully.

Depending on your specs and needs you may need to increase the swap file to a higher value, but it should always work to fix OOM issues.

Cornflakes answered 30/9, 2021 at 17:18 Comment(0)
B
-4

run the command as superuser:

sudo npm x-command
Brainchild answered 16/9, 2017 at 14:50 Comment(1)
This answer doesn't explain why this command would benefit the use case. Could you please elaborate on the reasons why this would be a valid solution?Sulfuric
S
-4

I Resolved this error, please enter following commands

npm install -g express-generator
express --view=hbs /tmp/foo && cd /tmp/foo
npm install
npm start
Straitjacket answered 18/4, 2018 at 10:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.