繁体   English   中英

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

[英]Error after running NPM start on react project

我已经将一个项目从以前的机器复制到我现在的机器上。 运行npm installnpm start我的终端出现此错误

sh:反应脚本:找不到命令
npm 错误! 文件sh
npm 错误! 代码生命周期
npm 错误! 错误号
npm 错误! 系统调用生成
npm 错误! 更新反应@0.1.0 开始:'反应脚本开始'
npm 错误! 生成 ENOENT
npm 错误!
npm 错误! 在renew_react@0.1.0 启动脚本失败。
npm 错误! 这可能不是 npm 的问题。 有可能
上面的附加日志输出。

npm 错误! 可以在以下位置找到此运行的完整日志:npm 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: 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:反应脚本开始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 ] 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 ] 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 ]关于如何在我的机器上启动的任何想法?

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

npm install create-react-app

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

我有一些类似的经历,但就我而言,这是一个我在同一台机器上工作的项目。 我会关闭电脑,几天后继续,但是当我运行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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM