3

I have had this issue for 3 days now. I used to get this error occasionally and it would just start working after a few troubleshooting commands, now npm start is not working at all and I keep getting this error.

Host Details:

Ubuntu server 18.04 LTS
Node v8.10.0
npm 6.10.2

I have tried the following in this order:

rm -rf node_modules
rm package-lock.json
npm install -g npm
npm install
npm start
sudo npm start

Then:

npm install create-react-app
npm install react-scripts
node node_modules/react-scripts/scripts/start.js

Also tried deleting the entire folder, making the directory and pulling from github again. Just to try it chown ubuntu project_folder

Nothing is working.

The app was created using create-react-app and it works fine on my desktop and my laptop.

Starting the development server...

The build failed because the process exited too early. This probably means the system ran out of memory or someone called `k
ill -9` on the process.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! REDACTED@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the REDACTED@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2019-08-05T14_02_01_500Z-debug.log

Data from /home/ubuntu/.npm/_logs/2019-08-05T14_02_01_500Z-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.10.2
3 info using node@v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle REDACTED@0.1.0~prestart: REDACTED@0.1.0
6 info lifecycle REDACTED@0.1.0~start: REDACTED@0.1.0
7 verbose lifecycle REDACTED@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle REDACTED@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/hom
e/ubuntu/code/bf_dev/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ga
mes:/snap/bin
9 verbose lifecycle REDACTED@0.1.0~start: CWD: /home/ubuntu/code/bf_dev
10 silly lifecycle REDACTED@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle REDACTED@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle REDACTED@0.1.0~start: Failed to exec start script
13 verbose stack Error: REDACTED@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:326:16
)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55
:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid REDACTED@0.1.0
15 verbose cwd /home/ubuntu/code/bf_dev
16 verbose Linux 4.15.0-1044-aws
17 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v8.10.0
19 verbose npm  v6.10.2
20 error code ELIFECYCLE
21 error errno 1
22 error REDACTED@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the REDACTED@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Any help is greatly appreciated.

boostedd
  • 268
  • 1
  • 3
  • 13
  • I am not sure where did you get the references of creating a react project with **CRA** syntax. If you've created your project with `npx create-react-app [app-name]` after having first installed `create-react-app` module by running `npm install -g create-react-app` in your console, you don't have to install `react-scripts` separately. Doing `npm start` should have just done the trick. – bijayshrestha Aug 05 '19 at 15:54

2 Answers2

1

I have had this error many times. After npm install create-react-app, check if create-react-app has been installed with the command create-react-app. It will show you that create-react-app has not been installed because you are not installing create-react-app on the folder where your project is. You just have to install create-react-app in right directory. Or you can install it globally with

npm install -g create-react-app

If you don't want to install it globally, go to the folder where your project is and then install create-react-app in that folder.

Basically, you are getting this error because create-react-app is not installed on your directory. This should fix your problem.

If this does not help, you can do the following:

Note: You’ll need to have Node >= 8.10 and npm >= 5.6 on your machine. Go to a desired folder. Then,

ngx create-react-app my-app
cd my-app
npm start

This is in the official documentation of create react app, So, this should work.

Amrit Subedi
  • 431
  • 3
  • 11
  • Thanks for the response. I have already tried npm install -g create-react-app and npm install create-react-app in the project directory. I'm still getting the same error message. – boostedd Aug 05 '19 at 15:58
  • Did you try sudo npm install -g create-react-app? – Amrit Subedi Aug 05 '19 at 16:00
  • Yes, I ran sudo npm install -g create-react-app. Still getting errors. – boostedd Aug 05 '19 at 16:05
  • I just tried: mkdir test npx create-react-app test npm start ,Same error. – boostedd Aug 05 '19 at 16:06
  • After you execute nxp create-react-app test, do cd test and then npm start. – Amrit Subedi Aug 05 '19 at 16:08
  • edited: tried cd test, then npm start This still fails with the same error. – boostedd Aug 05 '19 at 16:09
  • Oh wait. go to /home/ubuntu/code. Then execute npx create-react-app my-app, then cd my-app, then npm start. npx create-react-app my-app will automatically create a new folder named my-app inside code. – Amrit Subedi Aug 05 '19 at 16:13
  • Still getting the same error when running npm start in the new project directory created with npx create-react-app test – boostedd Aug 05 '19 at 16:15
  • check if create-react-app is installed by executing create-react-app. and execute pwd to know your current dir. I think it has to do with either create-reat-app is not installed or you are on wrong dir. There are no other possible explanations to why it isn't working. Check out this official doc from create-react-app. This might help. https://reactjs.org/docs/create-a-new-react-app.html – Amrit Subedi Aug 05 '19 at 16:18
  • create-react-app returns the help text, I am in the correct directory. This project works on 2 other machines with no issues. – boostedd Aug 05 '19 at 16:23
  • Ubuntu server 18.04 LTS Node v8.10.0 npm 6.10.2 My desktop is running Arch Linux. node v10.16.0, npm 6.10.1 which runs the project fine. This has worked in the past on the ubuntu server though. – boostedd Aug 05 '19 at 16:30
  • 1
    As far as I know, this should be working. I would recommend switching to higher version of Node just to see if that help. Ngx should work with your current version. I have no idea why this is failing on your machine. – Amrit Subedi Aug 05 '19 at 16:34
0

Thanks everyone for the replies. Looks like user error.

updated nodejs following this thread: How do I update Node.js?

and the project loads just fine, I guess with Arch being on the bleeding edge of software and the ubuntu repos being behind got to me.

boostedd
  • 268
  • 1
  • 3
  • 13