2016-10-10 82 views
25

我有一个项目,我没有接触2个星期。我收回,现在当我尝试运行npm start我得到了这个错误。npm启动错误与创建反应应用程序

> react-scripts start 

sh: react-scripts: command not found 

npm ERR! Darwin 16.0.0 
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" 
npm ERR! node v6.7.0 
npm ERR! npm v3.10.3 
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 'react-scripts start'. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the UpScore package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  react-scripts start 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs UpScore 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls UpScore 
npm ERR! There is likely additional logging output above. 
  • 节点6.7.0
  • NPM 3.10.3
  • MAC塞拉利昂10.12

的package.json

{ 
    "name": "UpScore", 
    "version": "0.6.0", 
    "private": true, 
    "devDependencies": { 
    "react-addons-test-utils": "^15.3.1", 
    "react-scripts": "0.4.1", 
    "react-test-renderer": "^15.3.1", 
    "redux-logger": "^2.6.1" 
    }, 
    "dependencies": { 
    "@yoshokatana/medium-button": "^1.1.0", 
    "axios": "^0.14.0", 
    "bcrypt": "^0.8.7", 
    "bcrypt-nodejs": "0.0.3", 
    "bcryptjs": "^2.3.0", 
    "body-parser": "^1.15.2", 
    "connect-flash": "^0.1.1", 
    "cookie-parser": "^1.4.3", 
    "draft-js": "^0.8.1", 
    "draft-js-editor": "^1.7.2", 
    "draft-js-export-html": "^0.4.0", 
    "ejs": "^2.5.2", 
    "email-verification": "^0.4.5", 
    "express": "^4.14.0", 
    "express-session": "^1.14.1", 
    "flexboxgrid": "^6.3.1", 
    "highlight.js": "^9.6.0", 
    "immutable": "^3.8.1", 
    "katex": "^0.6.0", 
    "lodash": "^4.15.0", 
    "markdown-it-mathjax": "^1.0.3", 
    "material-ui": "^0.15.4", 
    "medium-editor": "^5.22.0", 
    "minutes-seconds-milliseconds": "^1.0.3", 
    "moment": "^2.15.0", 
    "moment-duration-format": "^1.3.0", 
    "mongod": "^1.3.0", 
    "mongodb": "^2.2.9", 
    "mongoose": "^4.6.0", 
    "monk": "^3.1.2", 
    "morgan": "^1.7.0", 
    "normalize.css": "^3.0.3", 
    "passport": "^0.3.2", 
    "passport-local": "^1.0.0", 
    "react": "^15.3.1", 
    "react-dom": "^15.3.1", 
    "react-markdown": "^2.4.2", 
    "react-medium-editor": "^1.8.1", 
    "react-redux": "^4.4.5", 
    "react-redux-form": "^0.14.5", 
    "react-rich-markdown": "^1.0.1", 
    "react-router": "^2.7.0", 
    "react-router-redux": "^4.0.5", 
    "react-tap-event-plugin": "^1.0.0", 
    "react-tinymce": "^0.5.1", 
    "redux": "^3.6.0", 
    "redux-form": "^6.0.5", 
    "redux-form-material-ui": "^4.0.1", 
    "redux-promise-middleware": "^4.0.0", 
    "redux-thunk": "^2.1.0", 
    "reselect": "^2.5.3", 
    "screenfull": "^3.0.2" 
    }, 
    "scripts": { 
    "start": "react-scripts start", 
    "start:prod": "pushstate-server build", 
    "build": "react-scripts build", 
    "test": "react-scripts test --env=jsdom", 
    "eject": "react-scripts eject", 
    "server": "cd client/api && pm2 start server.js --watch", 
    "proxy": "http://128.199.139.144:3000" 
    }, 
    "eslintConfig": { 
    "extends": "./node_modules/react-scripts/config/eslint.js" 
    } 
} 

我试图克隆我的回购也和得到相同的错误。如果有人能给我一些方法来找到发生的事情。谢谢

+1

您是否试过移除您的'node_modules'并再次运行'npm install'? – Nitsew

+1

是的,我清理node_modules和npm install。我在npm安装中没有错误。 – EQuimper

+0

我用这个命令'rm -rf node_modules/&& npm cache clean && npm install' – EQuimper

回答

82

的作者创建应用程序作出反应在检查

你。绝对不应该在全球安装react-scripts
你也不要需要./node_modules/react-scripts/bin/package.json作为this answer暗示。

如果你看到这一点:

npm ERR! [email protected] start: `react-scripts start` 
npm ERR! spawn ENOENT 

这只是意味着出了问题时,依赖被安装的第一次。

我建议做以下三个步骤:

  1. npm install -g [email protected]更新NPM,因为它有时是马车。
  2. rm -rf node_modules删除现有模块。
  3. npm install重新安装项目依赖关系。

这应该解决问题。
如果没有,请联系file an issue,该链接指向您的项目以及Node和npm版本。

+2

谢谢你的工作;) – EQuimper

+0

这不适合我。 npm v3.3.1;节点v6.9.1。我在Windows上,并且在执行系统还原以回滚几个星期来修复另一个问题之后,此问题就开始了。 – MartinDuo

+0

P.S .:运行你的步骤,我得到这个错误。 'rm'不被识别为内部或外部命令。我认为系统恢复删除了运行这些节点命令所需的东西,但我不知道。 – MartinDuo

4

在你的全球环境中,你似乎没有react-scripts。 两种可能性都可以在这里:

npm install -g react-scripts

或在您的package.json改变你这样的脚本部分:

"scripts": { 
    "start": "./node_modules/react-scripts/bin/react-scripts.js start", 
    "start:prod": "pushstate-server build", 
    "build": "./node_modules/react-scripts/bin/react-scripts.js build", 
    "test": "./node_modules/react-scripts/bin/react-scripts.js test --env=jsdom", 
    "eject": "./node_modules/react-scripts/bin/react-scripts.js eject", 
    "server": "cd client/api && pm2 start server.js --watch", 
    "proxy": "http://128.199.139.144:3000" 
    }, 
+0

现在我遇到了index.html问题,看起来像公共目录中的create-react-app搜索?但在我从未得到那个之前。 – EQuimper

+1

看看更新日志;)https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#050-se- 2016-2016 –

+0

完美再次感谢你 – EQuimper

1

是的,你不应该在全球安装react-scripts,它不会工作。

我想我没有使用--save当我第一次创建项目(另一台机器上),所以对我来说这解决了这一问题:

npm install --save react react-dom react-scripts 
-1

它可能是与其他库发生冲突,删除node_modules并再次安装npm。

0

只要在termux中执行这个命令,你就可以走了。

pkg install termux-exec proot