503

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 ] 
2
  • 2
    Make sure you also have space left on the drive. Commented Jul 25, 2018 at 12:44
  • 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 stackoverflow.com/a/65399700/495157 (relative path of disable-browser-cache.js). ./ -> ../.. github.com/tapio/live-server/issues/245 Commented Dec 21, 2020 at 20:59

52 Answers 52

1
2
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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

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).

Comments

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.

Comments

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.

Comments

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

Comments

0

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

Comments

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

Comments

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.

Comments

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.

Comments

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 

Comments

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 

Comments

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 

Comments

0

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

You should upgrade Node.js version >= 16

Comments

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 ...

Comments

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.

Comments

0

Here on my ubuntu 18 node 10.24.1

i need to do this:

echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf sudo sysctl -p

nmp start

or you can try to rerun "npm install" if needed.

Comments

0

If you get an ELIFECYCLE running inside a container, you may just need to increase the memory the container is requesting.

For instance, in a Kubernetes yaml file just add/increase the resource.request:

containers: - name: my-container image: image-example:1.4.2 resources: requests: memory: 500M # add/increase this 

And perhaps adjust resources.limits.memory too.

Comments

-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!.

Comments

-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.

Comments

-4

run the command as superuser:

sudo npm x-command 

2 Comments

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?
This answer doesn't clearly explain why this statement is the solution. A more detailed explanation is needed.
-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 

Comments

1
2