我是新来的人,这是问题所在:
我的React应用在我安装react-router-dom
的Ubuntu计算机上正常运行
npm i --save react-router-dom
现在我无法开始反应了:
me@desktop:~/front-myapp$ npm start
> front-myapp@0.1.0 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! front-myapp@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the front-myapp@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/me/.npm/_logs/2018-09-03T04_38_54_369Z-debug.log
错误日志文件是这个:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@5.6.0
3 info using node@v8.11.4
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle front-myapp@0.1.0~prestart: front-myapp@0.1.0
6 info lifecycle front-myapp@0.1.0~start: front-myapp@0.1.0
7 verbose lifecycle front-myapp@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle front-myapp@0.1.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/me$
9 verbose lifecycle front-myapp@0.1.0~start: CWD: /home/me/front-myapp
10 silly lifecycle front-myapp@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 info lifecycle front-myapp@0.1.0~start: Failed to exec start script
12 verbose stack Error: front-myapp@0.1.0 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 front-myapp@0.1.0
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 front-myapp@0.1.0 start: `react-scripts start`
23 error spawn ENOENT
24 error Failed at the front-myapp@0.1.0 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
我的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"
}
}
我该如何解决?
答案 0 :(得分:2)
尽管很棘手:
rm -rf node_modules
npm install
应该做到这一点。
react-scripts
有点麻烦,因此很可能已从node_modules
文件夹中将其删除