在反应项目上运行NPM启动后出错

时间:2018-05-04 15:17:29

标签: node.js reactjs npm

我已将项目从之前的计算机复制到我当前的计算机上。跑完之后 npm installnpm start 我的终端发出此错误

sh:react-scripts:找不到命令
错误的ERR!文件sh
错误的ERR!代码ELIFECYCLE
错误的ERR!错误ENOENT
错误的ERR!系统调出生成
错误的ERR! renew_react@0.1.0 start:'react-scripts start'
错误的ERR!产生ENOENT
npm ERR!
错误的ERR!在renew_react@0.1.0启动脚本失败 错误的ERR!这可能不是npm的问题。可能有  上面的额外日志输出。

npm ERR!可以在以下位置找到此运行的完整日志: 错误的ERR! /Users/TimLowe/.npm/_logs/2018-05-04T15_10_08_807Z-debug.log

_logs/2018-05-04T15_10_08_807Z-debug.log中的代码是:

0 info it worked if it ends with ok 1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ] 2 info using npm@5.6.0 3 info using node@v10.0.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle renew_react@0.1.0~prestart: renew_react@0.1.0 6 info lifecycle renew_react@0.1.0~start: renew_react@0.1.0 7 verbose lifecycle renew_react@0.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle renew_react@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin 9 verbose lifecycle renew_react@0.1.0~start: CWD: /Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react 10 silly lifecycle renew_react@0.1.0~start: Args: [ '-c', 'react-scripts start' ] 11 info lifecycle renew_react@0.1.0~start: Failed to exec start script 12 verbose stack Error: renew_react@0.1.0 start: react-scripts start 12 verbose stack spawn ENOENT 12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18) 12 verbose stack at ChildProcess.emit (events.js:182:13) 12 verbose stack at maybeClose (internal/child_process.js:947:16) 12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:236:5) 13 verbose pkgid renew_react@0.1.0 14 verbose cwd /Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react 15 verbose Darwin 15.6.0 16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 17 verbose node v10.0.0 18 verbose npm v5.6.0 19 error file sh 20 error code ELIFECYCLE 21 error errno ENOENT 22 error syscall spawn 23 error renew_react@0.1.0 start: react-scripts start 23 error spawn ENOENT 24 error Failed at the renew_react@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 ] 关于我如何应对我的机器启动的任何想法?

2 个答案:

答案 0 :(得分:0)

您需要再次手动安装create-react-app包。它会将所有依赖项安装到您的新计算机上,包括react-scripts

npm install create-react-app

它应该作为全局安装,而不是任何特定项目的一部分。

答案 1 :(得分:0)

我有类似的经历,但就我而言,这是一个我在同一台机器上工作的项目。我将关闭PC,几天后再继续操作,但是当我运行npm start时,我会得到您遇到的错误。

这是我的解决方法:

  • 导航到我的项目目录
  • rm -rf node_modules删除节点模块文件夹
  • rm package-lock.json
  • npm cache clean --force
  • npm install
  • npm start

我再次遇到了类似的错误,这一次我已经在git中上传了我的项目,因此每次我要对其进行处理时,我都会执行git pull project_url然后: -npm install -npm start