Karlom
Karlom

Reputation: 14864

react does not start after installing react-router-dom

I'm new to react and here is the problem:

My react app was working fine on my Ubuntu machine unitl I installed react-router-dom

npm i --save  react-router-dom

Now I can not start react anymore:

me@desktop:~/front-myapp$ npm start

> [email protected] start /home/me/front-myapp
> react-scripts start

sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] 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/me/.npm/_logs/2018-09-03T04_38_54_369Z-debug.log

The erro log file is this:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/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 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/me$
9 verbose lifecycle [email protected]~start: CWD: /home/me/front-myapp
10 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ]
11 info lifecycle [email protected]~start: Failed to exec start script
12 verbose stack Error: [email protected] start: `react-scripts start`
12 verbose stack spawn ENOENT
12 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack     at emitTwo (events.js:126:13)
12 verbose stack     at ChildProcess.emit (events.js:214:7)
12 verbose stack     at maybeClose (internal/child_process.js:925:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
13 verbose pkgid [email protected]
14 verbose cwd /home/me/front-myapp
15 verbose Linux 4.15.0-33-generic
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
17 verbose node v8.11.4
18 verbose npm  v5.6.0
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error [email protected] start: `react-scripts start`
23 error spawn ENOENT
24 error Failed at the [email protected] start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

my package.json:

{
  "name": "front-myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.4.2",
    "react-dom": "^16.4.2",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "1.1.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

How can I fix this?

Upvotes: 0

Views: 503

Answers (1)

Alex Antonov
Alex Antonov

Reputation: 15186

Even though it's tricky:

  1. rm -rf node_modules
  2. npm install

Should do the trick.

react-scripts is a little bit troublesome package, so most likely, it has been removed somehow from node_modules folder

Upvotes: 2

Related Questions