首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用create-react-app时npm启动错误

使用create-react-app时npm启动错误
EN

Stack Overflow用户
提问于 2016-10-10 21:51:21
回答 21查看 229.3K关注 0票数 97

我有一个项目,我已经两周没碰过他了。我收回了它,现在当我尝试运行npm start时,我得到了这个错误。

代码语言:javascript
复制
> 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! UpScore@0.6.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the UpScore@0.6.0 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 sierra 10.12

package.json

代码语言:javascript
复制
{
  "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"
  }
}

我也尝试克隆我的repos,但得到了同样的错误。如果有人能给我一些方法让我知道发生了什么。谢谢

EN

回答 21

Stack Overflow用户

回答已采纳

发布于 2016-10-10 22:42:33

创建React应用程序签入的作者。

您绝对不应该全局安装 react-scripts

正如this answer所暗示的,你也不需要在package.json中使用./node_modules/react-scripts/bin/

如果您看到以下内容:

代码语言:javascript
复制
npm ERR! UpScore@0.6.0 start: `react-scripts start`
npm ERR! spawn ENOENT

这只是意味着在第一次安装依赖项时出现了错误。

我建议执行以下三个步骤:

使用

  1. npm install -g npm@latest来更新npm,因为移除已有的modules.
  2. npm install来重新安装项目dependencies.

有时需要使用buggy.

  • rm -rf node_modules

这应该可以解决这个问题。

如果没有,请在file an issue中加上您的项目以及Node和npm版本的链接。

票数 255
EN

Stack Overflow用户

发布于 2016-10-10 22:23:32

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

npm install -g react-scripts

或者在package.json中更改脚本部分,如下所示:

代码语言:javascript
复制
  "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"
  },
票数 11
EN

Stack Overflow用户

发布于 2017-09-22 20:53:26

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

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

代码语言:javascript
复制
npm install --save react react-dom react-scripts
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39959900

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档