Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm start error with create-react-app

I have a project who I didn't touch for 2 weeks. I take it back and now when I try to run npm start I got this error.

> 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. 
  • node 6.7.0
  • npm 3.10.3
  • mac sierra 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"   } } 

I try to clone my repos too and get the same error. If someone can give me some way to find what happen. Thank you

like image 208
EQuimper Avatar asked Oct 10 '16 13:10

EQuimper


People also ask

Can I use npm With create react app?

Create React App is a comfortable environment for learning React, and is the best way to start building a new single-page application in React. npx on the first line is not a typo — it's a package runner tool that comes with npm 5.2+.

Why NPX create react app not working?

We no longer support global installation of Create React App. The current solution is simple — run create-react-app and target the latest version. Different versions of npm may help as well, and you can upgrade using the following command. Please note that this may affect other projects on your system.

What does npm start do in create react app?

With the start argument, NPM will begin the process to make a development server available for your React application. Here's a list of tasks for this script: Set the build environment into development for Node and Babel. Ensure environment variables are read for the build process.


1 Answers

Author of Create React App checking in.

You absolutely should not be installing react-scripts globally.
You also don't need ./node_modules/react-scripts/bin/ in package.json as this answer implies.

If you see this:

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

It just means something went wrong when dependencies were installed the first time.

I suggest doing these three steps:

  1. npm install -g npm@latest to update npm because it is sometimes buggy.
  2. rm -rf node_modules to remove the existing modules.
  3. npm install to re-install the project dependencies.

This should fix the problem.
If it doesn't, please file an issue with a link to your project and versions of Node and npm.

like image 173
Dan Abramov Avatar answered Sep 30 '22 08:09

Dan Abramov