create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

'react-scripts' is not recognized as an internal or external command

Open ianHunterClipd opened this issue 7 years ago • 25 comments

Is this a bug report?

Yes

I have cleared both node_modules and package-lock.json via Powershell.

After npm install -g npm@latest npm -v 6.9.0

After npm install && npm start 'react-scripts' is not recognized as an internal or external command...

Which terms did you search for in User Guide?

Troubleshoot, create-react-app, react-scripts, "not recognized as an internal or external command", npm scripts

Environment

npx create-react-app --info npx: installed 63 in 14.404s

Environment Info:

System: OS: Windows 10 CPU: x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz Binaries: npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: 44.17763.1.0 Internet Explorer: 11.0.17763.1 npmPackages: react: ^16.8.4 => 16.8.4 react-dom: ^16.8.4 => 16.8.4 react-scripts: 2.1.8 => 2.1.8 npmGlobalPackages: create-react-app: Not Found

Steps to Reproduce

(Write your steps here:)

  1. cd C:\Users\notMyUsername\Documents\Project\react\
  2. npx create-react-app test
  3. cd test
  4. npm start

Expected Behavior

It is expected that the development server should launch through the default browser (firefox) on port 3000.

Actual Behavior

'react-scripts' is not recognized as an internal or external command, operable program or batch file.

startError

2019-03-08T21_07_52_062Z-debug.log

Reproducible Demo

I don't have project code yet because I can't get the project to launch :( Strangely enough, I have another React project that was created with create-react-app ~6 months ago in the same parent directory as the test project and I don't have any problems with it.

UPDATE After hitting this post https://github.com/facebook/create-react-app/issues/6197 the OP mentioned that running npx react-scripts start was able to start the development server. This is true for me as well, if this is any help for others. Still no luck with npm start. I have also tried this procedure with yarn and get the same results :(

ianHunterClipd avatar Mar 08 '19 21:03 ianHunterClipd

@ianHunterClipd is "react-scripts" present in your dependencies/devDependencies ?

fazouane-marouane avatar Mar 09 '19 16:03 fazouane-marouane

Yes, react scripts is listed as a dependency in my package.json file ... "dependencies": { "react": "^16.8.4", "react-dom": "^16.8.4", "react-scripts": "2.1.8" } ...

As another test I spun up an ec2 instance with Ubuntu and (successfully) created a project with create-react-app. Pushed that project to git and pulled it back down to my local dev environment and encountered the same issue. In my mind it seems like this is some sort of PATH issue but the PATH listed in the debug log seems like it should be sufficient. Cheers,

Ian

ianHunterClipd avatar Mar 09 '19 17:03 ianHunterClipd

Took another stab at this problem today and made some headway. After doing more research about npm scripts and package.json files, I eventually tried running the react-scripts script from node-modules/.bin manually and whalla! the development server launches as desired. At least I can work on my project now :P

I am still curious as to what is causing this problem though. I am trying to work backwards from this line from the error log

17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\notMyUsername\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"

I can call the first part of that command with

node

in Powershell. Once I'm in the node shell, how would I load the npm-cli and then run react-scripts?

Second, if I wanted to view verbose debugging output from a project where

npm start

launches the development server as desired, how would I go about doing that?

ianHunterClipd avatar Mar 14 '19 20:03 ianHunterClipd

You're probably missing ./node_modules/.bin in your path; normally the node installation will add this for you.

dxmann73 avatar Mar 19 '19 07:03 dxmann73

@dxmann73 You are correct that ./node_modules/.bin directory is not in my user or system path. However, as I mentioned, I have a second project in the same parent directory as the failing project that works as expected, and it's local bin is also not in my path variable.

ianHunterClipd avatar Mar 20 '19 19:03 ianHunterClipd

i ran into similar problem on windows 10 with cygwin...

if i change package.json and add a '.cmd' suffix to react-scripts references i no longer get the above error.

it looks like nodejs is confused about windows vs. cygwin vs. windows-bash... setting NODE_DEBUG=* indicates that PATH is being changed correctly internally but then windows cmd.exe is being used to run the command(react-scripts) but cannot find it...

further inspection of nodejs indicates questionable decision design for example node_modules/npm/lib/utils/is-windows-bash.js contains "process.env.TERM === 'cygwin'", which makes no sense as a way to detect cygwin, and is no longer valid for cygwin terminal emlation via mintty,

mitchbassProbus avatar Mar 27 '19 14:03 mitchbassProbus

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

stale[bot] avatar Apr 26 '19 15:04 stale[bot]

@mitchbassProbus I suspect you are correct as I have a similar stack on my machine (Windows 10 + Windows Bash + Cygwin) but I haven't explored the issue further. For development I have resorted to launching the react-scripts functionality from the local node_modules/.bin directory and haven't had any snags.

ianHunterClipd avatar Apr 26 '19 22:04 ianHunterClipd

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

stale[bot] avatar May 26 '19 23:05 stale[bot]

I'm also having difficulties with this when running from a cmd console in windows 10. Since the default is going for "react-scripts start" or running "npm run start" (and that usually points to "react-scripts start"), this error is plainly confusing for new people.

ManuelZ avatar May 27 '19 18:05 ManuelZ

I have run into this as well and my solution was to reinstall NVM for Windows I am using and let it (re)take control over the installed NPM version upon being asked to do so by the installer. This fixes all PATH issues.

Another option is to use the NodeJS command prompt recent versions of Node install. That saved me when nothing else worked.

I can't share this in #1627 as it is locked, so hopefully it will help someone here.

TomasHubelbauer avatar May 28 '19 08:05 TomasHubelbauer

I am just using powershell (though I have WSL installed, I'm not using it for this), and used the following command to make it work, since yarn start fails. This isn't ideal, but at least it works.:

> .\node_modules\.bin\react-scripts.cmd start

rschuetzler avatar Jul 03 '19 01:07 rschuetzler

FWIW "npx react-scripts start" also worked for me at some point. This issue went away for me with a Windows update completely, but I settled on that while it was happening. Since react-scripts is already in node_modules, NPX will not download or install anything, it will just execute it.

TomasHubelbauer avatar Jul 03 '19 06:07 TomasHubelbauer

Strange. Tried npx react-scripts start this morning and it still downloaded it even though it's in the node_modules directory.

rschuetzler avatar Jul 03 '19 11:07 rschuetzler

@rschuetzler As a warning, I had some strange polyfill issues when trying to build the code for production via .\node_modules.bin\react-scripts build

ianHunterClipd avatar Jul 04 '19 18:07 ianHunterClipd

@ianHunterClipd Try using npm i -g react-scripts I was having the same error and was fixed might fix your problem too

ShivamRawat0l avatar Jul 07 '19 09:07 ShivamRawat0l

I don't remember why and I'm on mobile so I can't look it up but either up thread or for sure on Stack Overflow the maintainers said you shouldn't install React Scripts globally. Like I said though I'm not sure why exactly was it.

TomasHubelbauer avatar Jul 07 '19 09:07 TomasHubelbauer

I am also having this issue. I'm using: Node v10.16.0 npm 6.10.0

When I do npm ls react, only this shows up: └── [email protected]

FeerassE avatar Jul 09 '19 14:07 FeerassE

I am just using powershell (though I have WSL installed, I'm not using it for this), and used the following command to make it work, since yarn start fails. This isn't ideal, but at least it works.:

> .\node_modules\.bin\react-scripts.cmd start

I'm having the same issue and this worked for me. Any luck finding a fix for npm start?

joosebox avatar Jul 11 '19 07:07 joosebox

npm ls and then manually install all npm ERR! missing: packages it solved my problem

bhaskarChowdaryA avatar Jul 18 '19 08:07 bhaskarChowdaryA