Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm start fails: sh: react-scripts: command not found #3256

Closed
JulienDemarque opened this issue Oct 9, 2017 · 21 comments
Closed

npm start fails: sh: react-scripts: command not found #3256

JulienDemarque opened this issue Oct 9, 2017 · 21 comments

Comments

@JulienDemarque
Copy link

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

yes

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

  1. node -v: v6.11.1
  2. npm -v: 5.3.0
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven’t ejected): 1.0.14

Then, specify:

  1. Operating system: OSX Sierra 10.12.6
  2. Browser and version (if relevant):

Steps to Reproduce

(Write your steps here:)

  1. npm install -g create-react-app
  2. create-react-app my-app ... cd my-app/
  3. npm start

Expected Behavior

(Write what you thought would happen.)

Starts the development server.

Actual Behavior

(Write what happened. Please add screenshots!)

screen shot 2017-10-09 at 11 55 51

2017-10-09T08_48_47_494Z-debug.log

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

@gaearon
Copy link
Contributor

gaearon commented Oct 9, 2017

npm 5.3 is known to be buggy. Please update to more recent versions.

That said you can probably repair the project by running npm install in its folder.

@gaearon gaearon closed this as completed Oct 9, 2017
@gaearon
Copy link
Contributor

gaearon commented Oct 9, 2017

Can you also reproduce the problem with npm 4.x?

yes

Are you sure? Please attach a screenshot demonstrating that.

@JulienDemarque
Copy link
Author

Thank you for feedback,

Unfortunately it is still the same with npm 4.x...

screen shot 2017-10-09 at 16 09 21

creat-react-app shows a warning, if that is connected in any ways:
screen shot 2017-10-09 at 16 11 09

@gaearon
Copy link
Contributor

gaearon commented Oct 9, 2017

Oh, it seems like you use Yarn. So the npm version wasn't relevant.
Can you paste the output of ls node_modules?

@gaearon gaearon reopened this Oct 9, 2017
@JulienDemarque
Copy link
Author

JulienDemarque commented Oct 9, 2017

I installed with npm and created the app with npm, I don't know why it suggested me yarn...

Here is the ls node_modules:

(edited to remove a very long list)

@JulienDemarque
Copy link
Author

If I try yarn start I get this error message:
screen shot 2017-10-09 at 17 11 56

@sundvall
Copy link

I had the similar problem and tried to solve it with 'npm install' that eventually ended up in a non completed process that was very hard to stop.
After updating npm from 3.10.3 to 5.4.2 the 'npm install' went smoothly, and the 'react-scripts' could be used as expected.

@KasunWijesekara
Copy link

KasunWijesekara commented Oct 18, 2017

@sundvall do you know how to update npm to 5.4.2? I have tried multiple methods and nothing worked so far.

Current npm version - 3.10.10
Having "create-react-app" issues.

@sundvall
Copy link

sundvall commented Oct 18, 2017

To update npm:
npm -v gave the following hint:
npm i -g npm

Although I used another:
npm install npm@latest -g

@gaearon
Copy link
Contributor

gaearon commented Oct 18, 2017

Uninstall Yarn if you're having issues caused by Yarn.
Then report them to Yarn please.

You are not using npm—if you have Yarn installed, CRA will attempt to use it.
You can delete Yarn from your system and try again if you don't want to use it.

@JulienDemarque
Copy link
Author

I removed yarn and updated npm to 5.5.1 and the problem persist.
create-react-app is using webpack? I have the same issue trying to use webpack on my computer...

screen shot 2017-10-18 at 19 34 40

@marcelorl
Copy link

Hi @JulienDemarque

try this:

npm ls react

the response should be something like this:

Marcelo-Rizzardo:test marcelo$ npm ls react
test@0.1.0 /Users/marcelo/Development/test
├── react@16.0.0
└─┬ react-scripts@1.0.14
  └─┬ react-dev-utils@4.1.0
    └─┬ react-error-overlay@2.0.2
      └── react@16.0.0  deduped

Notice, it is important you to have this react-scripts@1.0.14 line.

how is it for you?

@JulienDemarque
Copy link
Author

Here is the result, looks good:
Juliens-MacBook-Pro:my-app juliendemarque$ npm ls react
my-app@0.1.0 /Users/juliendemarque/Desktop/Personnal matters/Programming:Coding/testreact/my-app
├── react@16.0.0
└─┬ react-scripts@1.0.14
└─┬ react-dev-utils@4.1.0
└─┬ react-error-overlay@2.0.2
└── react@16.0.0 deduped

@marcelorl
Copy link

one more:

if you navigate to node_modules/.bin/ can you find the file react-scripts in there?

what if you try running: node_modules/.bin/react-scripts start is there any issue?

@JulienDemarque
Copy link
Author

react-scripts are there but the commant didn't work, did you mean "npm react-scripts start"?

Juliens-MacBook-Pro:node_modules juliendemarque$ cd .bin
Juliens-MacBook-Pro:.bin juliendemarque$ ls
acorn errno html-minifier mime semver uglifyjs
ansi-html escodegen jest mkdirp sha.js uuid
babylon esgenerate jest-runtime multicast-dns sshpk-conv webpack
browserslist eslint js-yaml rc sshpk-sign webpack-dev-server
cssesc esparse jsesc react-scripts sshpk-verify which
csso esvalidate json5 regjsparser strip-indent
detect handlebars loose-envify rimraf svgo
detect-port he miller-rabin sane sw-precache
Juliens-MacBook-Pro:.bin juliendemarque$ react-scripts start
-bash: react-scripts: command not found
Juliens-MacBook-Pro:.bin juliendemarque$

@kale-stew
Copy link

I am having this same issue in multiple projects. I tried npm start in a vanilla create-react-app project, with no modifications, and am still reaching this error. I then tried updating npm globally using npm i -g npm, then rm -rf node_modules && npm i --save and still reach the error. Really looking forward to finding a solution here. 👎

@kale-stew
Copy link

@marcelorl I have that exact same output when I run npm ls react. Is your npm start functioning? Can I see your package.json?

calculator-app@0.1.0 /Users/ka_stewart/devmtn:notes/React.js/calculator-app
├── react@16.0.0
└─┬ react-scripts@1.0.14
  └─┬ react-dev-utils@4.1.0
    └─┬ react-error-overlay@2.0.2
      └── react@16.0.0  deduped

@JulienDemarque
Copy link
Author

Here is the full content of package.json:

{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-scripts": "1.0.14"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}

@shinxi
Copy link

shinxi commented Oct 27, 2017

Some suggestions. Try

  • Uninstall yarn.
npm uninstall -g yarn
  • Do a cache clean.
npm cache clean -f
  • If still doesn't work, try to downgrade/upgrade your npm version to npm 5.4.2 or npm 5.3.*
npm install -g npm@5.4.2

@gaearon
Copy link
Contributor

gaearon commented Oct 29, 2017

There's nothing we can do on our side to solve this.

If you are having this issue, remove package-lock.json if you have one, remove yarn.lock if you have one, and remove node_modules.

Then, if you use Yarn, run yarn. If after this yarn start doesn't work, upload your project to GitHub and file an issue in Yarn repository.

If you use npm, run npm install. If after this npm start doesn't work, upload your project to GitHub and file an issue in npm repository.

@gaearon gaearon closed this as completed Oct 29, 2017
@facebook facebook locked and limited conversation to collaborators Oct 29, 2017
@gaearon
Copy link
Contributor

gaearon commented Jan 17, 2018

I'd also add that this always happens if your project was created with Yarn (because you have it on your system) but then you attempt to npm install something. If you use Yarn, always do yarn add. I filed an issue about this here: yarnpkg/yarn#5240.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants