2016-10-10 78 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