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

Javascriptnode.jsReactjsMaven

Javascript Problem Overview


I've got a maven project, within which is JavaScript project cloned as a git sub-module. So the directory structure looks like mavenapp/src/main/javascript/[npm project files]

Inside my package.json, the test looks like this:

"test": "react-scripts test --env=jsdom",

but when I try to run npm test, it says

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

Interestingly, when I clone the javascript project independently I don't get this error. I've tried re-running npm install.

NPM version: 5.5.1
Node.js version: 9.3.0

Javascript Solutions


Solution 1 - Javascript

It is an error about react-scripts file missing in your node_modules/ directory at the time of installation.

Check your react-script dependency is avaliable or not in package.json.

If not available then add it manually via:

npm install react-scripts --save

Solution 2 - Javascript

If react-scripts is present in package.json, then just type this command

npm install

If react-scripts is not present in package.json, then you probably haven't installed it. To do that, run:

npm install react-scripts --save

Solution 3 - Javascript

Try:

rm -rf node_modules && npm install

Wiping node_modules first, often tends to fix a lot of weird, package related issues like that in Node.

Solution 4 - Javascript

Running these commands worked for me:

npm cache clean --force
npm rebuild
npm install

Solution 5 - Javascript

In my situation, some problems happened with my node package. So I run npm audit fix and it fixed all problems

Solution 6 - Javascript

Faced the same problem, although I am using yarn.

The following worked for me:

yarn install 
yarn start

Solution 7 - Javascript

Running the npm update command solved my problem.

Solution 8 - Javascript

To avoid this issue to re-occur or you face this issue whenever anyone downloads your project fresh.

It's better to add this in dev dependencies using this command:

npm install react-scripts --save-dev

It will get added like this.

  "devDependencies": {
    "react-scripts": "^4.0.3"
  }

Do Commit and push your code.

Solution 9 - Javascript

To rectify this issue follow the following steps

  1. run npm install
  2. then run npm start

This worked fine for me

Solution 10 - Javascript

2022 answer: simply remove node_modules folder and run

npm install

or:

yarn

it worked for me

Solution 11 - Javascript

react-scripts should be listed as a dependency when you run npx create-react-app your-app, but for some reason, it gets this error. I will list some steps that I followed that may help you fix this error:


First, check at your React package.json if there is react-scripts or not: for example, you should see:

"dependencies": {
    ...
    "react-scripts": "4.0.3",
    ...
  },

If it's already there, now try to re-install your dependencies with npm i


If you still get the same error, try to remove your node_modules with rm -rf node_modules/, then re-install your dependencies with npm i


BUT if the package react-scripts wasn't in your package.json file, you should install it by your package manager like: npm i react-scripts then try to start your app with npm start

Solution 12 - Javascript

  1. I uninstalled my Node.js and showed hidden files.

  2. Then, I went to C:\Users\yourpcname\AppData\Roaming\ and deleted the npm and npm-cache folders.

  3. Finally, I installed a new version of Node.js.

Solution 13 - Javascript

I faced the same issue. I solved it using npm audit fix --force

Solution 14 - Javascript

react-scripts is not recognized as an internal or external command is related to npm.

I would update all of my dependencies in my package.json files to the latest versions in both the main directory and client directory if applicable. You can do this by using an asterisk "*" instead of specifying a specific version number in your package.json files for your dependencies.

For Example:

"dependencies": {
    "body-parser": "*",
    "express": "*",
    "mongoose": "*",
    "react": "*",
    "react-dom": "*",
    "react-final-form": "*",
    "react-final-form-listeners": "*",
    "react-mapbox-gl": "*",
    "react-redux": "*",
    "react-responsive-modal": "*",
  }

I would then make sure any package-lock.json were deleted and then run npm install and yarn install in both the main directory and the client directory as well if applicable.

You should then be able to run a yarn build and then use yarn start to run the application.

Solution 15 - Javascript

For Portable apps change

> package.json

as follows

"scripts": {
    "start": "node node_modules/.bin/react-scripts start",
    "build": "node node_modules/.bin/react-scripts build",
    "test": "node node_modules/.bin/react-scripts test",
    "eject": "node node_modules/.bin/react-scripts eject"
  }

Solution 16 - Javascript

This is how I fix it

  1. Check and Update the path variable (See below on how to update the path variable)
  2. Delete node_modules and package-lock.json
  3. run npm install
  4. run npm run start

if this didn't work, try to install the nodejs and run repair

or clean npm cache npm cache clean --force

To update the path variable

  1. press windows key
  2. Search for Edit the system environmental variable
  3. Click on Environment Variables...
  4. on System variable bottom section ( there will be two section )
  5. Select Path variable name
  6. Click Edit..
  7. Check if there is C:\Program Files\nodejs on the list, if not add this

Solution 17 - Javascript

I had the same issue. I did everything which suggested here. but nothing worked. I had installed react-scripts in my node_modules also used cache but all in vain. then I just npx create-react-app and moved all my code into this new folder and all worked.

npx create-react-app myapp

Solution 18 - Javascript

first run:

npm ci

then:

npm start

Solution 19 - Javascript

Use git bash or windows cmd with admin rights to run npm install while fixing this issue, running these commands inside the editor's terminals doesn't help.

Solution 20 - Javascript

I have tried many of the solutions to this problem found on line, but in my case nothing worked except for reinstalling NVM for Windows (which I am using to manage multiple Node versions). In the installer, it detects installed Node versions and asks the user if they wish for NVM to control them. I said yes and NVM fixed all PATH issues. As a result, things worked as before. This issue may have multiple causes, but corrupted PATH is definitely one of them and (re)installing NVM fixes PATH.

Solution 21 - Javascript

This is rather old question but this might be of some help for future reference. Delete node_modules folder and run npm install again. Worked for me.

Solution 22 - Javascript

In my case , I edited my files on Linux where I had node v14.0.5 installed, when I rebooted to Windows where I had node v14.0.3 I got the same error. So I updated the node version on windows and all went fine for me.

Solution 23 - Javascript

had similar issue.. i used yarn to fix it. i noticed that react-scripts was not found in my node modules so i decided to download it with npm but i seem to be failing too. so i tried yarn ( yarn add react-scripts) and that solved the nightmare! Hope this work for you as well. Happy debuging folks.

Solution 24 - Javascript

For me, I just re-installed the react-scripts instead of react-scripts --save.

Solution 25 - Javascript

Started getting this error in Azure DevOps yesterday out of nowhere when running npm run build:

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

However when looking at npm ci that completed it was full of errors like:

> FetchError: Invalid response body while trying to fetch > https://registry.npmjs.org/@babel%2fcompat-data: ENOENT: no such file > or directory, lstat > 'D:\a\1.npm_cacache\content-v2\sha512\58\0b\dc7dce0b33e86d97736b3c419005951e32af28dda3f5b8c746f16d53d4baed1dc2fd2493e9310f744696008400bf8c91ca84f9fb3ebf541ba93a541b144a'

When commenting out the cache everything started working again:

npm_config_cache: $(Pipeline.Workspace)/.npm

- task: Cache@2
  inputs:
    key: 'npm | "$(Agent.OS)" | $(clientApp)\package-lock.json'
    restoreKeys: |
       npm | "$(Agent.OS)"
    path: $(npm_config_cache)
  displayName: Cache npm

The weird thing is that it has worked for over a year up until yesterday (2021-12-02) and we use the exact same code for caching as Microsoft has documented.

https://docs.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#nodejsnpm

Noting Degraded or Unhealthy on Azure DevOps Status

https://status.dev.azure.com/

Solution 26 - Javascript

As for me i managed to fix this issue by install this :

npm audit fix --force

and it work after that.

Solution 27 - Javascript

In my case, the problem had to do with not having enough file permissions for some files the react-scripts package installation was going to write to. What solved it was running git bash as an administrator and then running npm install --save react-scripts again.

Solution 28 - Javascript

When I make a new project using React, to install the React modules I have to run "npm install" (PowerShell) from within the new projects ClientApp folder (e.g. "C:\Users\Chris\source\repos\HelloWorld2\HelloWorld2\ClientApp"). The .NET core WebApp with React needs to have the React files installed in the correct location for React commands to work properly.

Solution 29 - Javascript

This worked for me:

  • Go to the project folder in CLI and type npm install.Go for a similar command if using yarn etc.

  • Then type npm start if you are using Npm. Go for a similar command if using yarn etc.

  • The file starts working

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJ SmithView Question on Stackoverflow
Solution 1 - JavascriptYogesh BoradView Answer on Stackoverflow
Solution 2 - JavascriptHadi MirView Answer on Stackoverflow
Solution 3 - JavascriptJonny AsmarView Answer on Stackoverflow
Solution 4 - JavascriptcrispengariView Answer on Stackoverflow
Solution 5 - JavascriptNguyen Duc ThanhView Answer on Stackoverflow
Solution 6 - JavascriptPope FrancisView Answer on Stackoverflow
Solution 7 - JavascriptMiraj KhandakerView Answer on Stackoverflow
Solution 8 - JavascriptKushalSethView Answer on Stackoverflow
Solution 9 - JavascriptPaa SoloView Answer on Stackoverflow
Solution 10 - JavascriptRaskulView Answer on Stackoverflow
Solution 11 - JavascriptHessahView Answer on Stackoverflow
Solution 12 - JavascriptSandro CagaraView Answer on Stackoverflow
Solution 13 - JavascriptraghurajjView Answer on Stackoverflow
Solution 14 - JavascriptAhmedakhtar11View Answer on Stackoverflow
Solution 15 - JavascriptsmamranView Answer on Stackoverflow
Solution 16 - JavascriptSalmanView Answer on Stackoverflow
Solution 17 - JavascriptMubasher AliView Answer on Stackoverflow
Solution 18 - JavascriptEmir MamashovView Answer on Stackoverflow
Solution 19 - JavascriptHarimangal PandeyView Answer on Stackoverflow
Solution 20 - JavascriptTomáš HübelbauerView Answer on Stackoverflow
Solution 21 - JavascriptKoder90View Answer on Stackoverflow
Solution 22 - JavascriptSourabhView Answer on Stackoverflow
Solution 23 - JavascriptEmmanuel SewahView Answer on Stackoverflow
Solution 24 - JavascriptSreesankar G WarrierView Answer on Stackoverflow
Solution 25 - JavascriptOgglasView Answer on Stackoverflow
Solution 26 - JavascriptChadrack KyunguView Answer on Stackoverflow
Solution 27 - JavascriptAdim VictorView Answer on Stackoverflow
Solution 28 - JavascriptChristopher UptonView Answer on Stackoverflow
Solution 29 - JavascriptMuhammad MoizView Answer on Stackoverflow