'How to fix 'rimraf is not a recognized command' in Windows 10
After creating the .NET Core / React & Redux project template and attempting to start the application, the react compile crashes with rimraf not recognized.
This is on Windows 10, node.js version 10.15.3. I have tried uninstalling/installing node.js multiple times and running multiple different npm commands. It seems like powershell is incorrectly linking to rimraf for some reason.
npm echo %PATH%
provides the correct path to the ./node_modules/.bin directory. And running that path followed by e.g. /rimraf
works properly. The command in package.json
is "start": "rimraf ./build && react-scripts start"
.
Solution 1:[1]
I had to manually run npm install to make it work.
open command line (e.g. from Visual Studio: Tools -> Command Line -> Developer Command Prompt)
go to ClientApp (cd ClientApp
) folder of your project and type:
npm install
Solution 2:[2]
I finally got rid of this error by installing rimraf globally
npm install rimraf -g
Solution 3:[3]
install:
npm install rimraf --save-dev
set your custom command in package.json:
"scripts": {
"build": "node_modules/.bin/rimraf build && tsc",
"start": "node build/index.js"
}
Use it
npm run build
Solution 4:[4]
Delete node modules folder in your web project. Do npm install.
Solution 5:[5]
Specifically, if you get this error,
"rimraf' is not recognized"
First of all, the below assumes you have node installed. To check if nodejs is installed, open a cmd/powershell window and type: node -v
It should return the version number.
Also, before you do a build in VS2019, make sure you have updated all the nuget packages.
After verifying the above, do the following:
- go to the myappproject/clientapp folder and delete the /nodemodules folder.
- from the clientapp folder, open up a powershell or cmd prompt
- run npm install
Rebuild. This should fix the problem.
Solution 6:[6]
I got the same issue, but rimraf was already installed globally. Had to manually delete node modules and then install them back again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | antonpv |
Solution 2 | alban maillere |
Solution 3 | |
Solution 4 | Sai Vaibhav Medavarapu |
Solution 5 | Andrew H |
Solution 6 | Ramindu Samarawickrama |