安装react-router-dom后,react不会启动

问题描述 投票:0回答:1

我有新的反应,这是问题所在:

我的反应应用程序在我的Ubuntu机器上工作正常,直到我安装了qazxsw poi

react-router-dom

现在我不能再开始反应了:

npm i --save  react-router-dom

错误日志文件是这样的:

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

我的package.json:

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 ]

我怎样才能解决这个问题?

reactjs
1个回答
2
投票

即使它很棘手:

  1. { "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" } }
  2. rm -rf node_modules

应该做的伎俩。

npm install是一个有点麻烦的包,所以很可能,它已被从react-scripts文件夹中删除

© www.soinside.com 2019 - 2024. All rights reserved.