在反应项目上运行 NPM 启动后出错 [英] Error after running NPM start on react project

查看:98
本文介绍了在反应项目上运行 NPM 启动后出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将一个项目从以前的机器复制到我当前的机器上.跑完后npm 安装npm start我的终端出现这个错误

I have copied a project from a previous machine to my current machine. after running npm install And npm start my terminal gives this error

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

sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! renew_react@0.1.0 start: 'react-scripts start'
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the renew_react@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.

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

npm ERR! A complete log of this run can be found in: 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 如果它以 ok 结尾,它就起作用了1 详细 cli ['/usr/local/bin/node', '/usr/local/bin/npm', 'start']2 信息使用 npm@5.6.03 信息使用 node@v10.0.04 详细的运行脚本 ['prestart', 'start', 'poststart']5 info生命周期renew_react@0.1.0~prestart:renew_react@0.1.06 生命周期信息renew_react@0.1.0~开始:renew_react@0.1.07 冗长的生命周期renew_react@0.1.0~start: unsafe-perm in lifecycle true8 详细的生命周期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/bin9 详细生命周期renew_react@0.1.0~start: CWD:/Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react10 愚蠢的生命周期renew_react@0.1.0~start: Args: [ '-c', 'react-scripts start' ]11 info生命周期renew_react@0.1.0~start: 执行启动脚本失败12 详细堆栈错误:renew_react@0.1.0 start:react-scripts start12 冗长的堆栈生成 ENOENT12 ChildProcess 中的详细堆栈.(/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)ChildProcess.emit 上的 12 个详细堆栈 (events.js:182:13)12 详细堆栈在可能关闭 (internal/child_process.js:947:16)Process.ChildProcess._handle.onexit (internal/child_process.js:236:5) 上的 12 个详细堆栈13 详细 pkid 更新反应@0.1.014 详细 cwd/Users/TimLowe/Desktop/CodeBridge:WDI/project4_Renew/Renew/renew_react15 冗长的达尔文 15.6.016 详细 argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"17 详细节点 v10.0.018 冗长的 npm v5.6.019 错误文件sh20 错误代码 ELIFECYCLE21 错误 errno ENOENT22 错误系统调用产生23 错误renew_react@0.1.0 start:react-scripts start23 错误产生 ENOENT24 错误在renew_react@0.1.0 启动脚本失败.24 错误 这可能不是 npm 的问题.上面可能有额外的日志输出.25 详细退出 [ 1, true ]关于如何在我的机器上启动的任何想法?

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 ] Any ideas on how I can get react to start on my machine?

推荐答案

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

I had a somewhat similar experience but in my case it was a project that I'm working on my same machine. I'd turn off PC, come after a few days to continue but when I run npm start I'd get the error you are having.

我是这样解决的:

  • 导航到我的项目目录
  • rm -rf node_modules 删除节点模块文件夹
  • rm package-lock.json
  • npm 缓存清理 --force
  • npm install
  • npm start
  • Navigated to my project directory
  • rm -rf node_modules to delete the node modules folder
  • rm package-lock.json
  • npm cache clean --force
  • npm install
  • npm start

我又遇到了类似的错误,这次我已经在git中上传了我的项目,所以每次我想处理它时,我都会做一个git pull project_url然后:- npm 安装- npm start

I ran into a similar error again, this time I had already uploaded my project in git, so each time I want to work on it, I'd do a git pull project_url then: - npm install - npm start

这篇关于在反应项目上运行 NPM 启动后出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆