Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run rm command on windows 10?

"build": "rm -rf ./build && mkdir ./build && ./node_modules/.bin/babel -d ./build ./src"

This is the command in package.json and it gives me an error saying:

rm is not recognized as internal or external command.
Invalid switch /build
like image 468
Ghayyour Ahmed Butt Avatar asked Jan 03 '17 20:01

Ghayyour Ahmed Butt


People also ask

What is rm RF in Windows?

CMD: Delete Folder (Force `RMDIR`) – Windows The rm -rf command in Linux is used to force the deletion of folders and their contents recursively. The rmdir command is a Windows rm equivalent in a Windows command prompt (CMD), that also can be used to force the folders deletion with all their contents.


Video Answer


4 Answers

That script was written for the UNIX shell, which does not work on windows. The correct way to do this in a cross-platform way is to use rimraf & mkdirp.

Also, the ./node_modules/.bin/babel portion could be shortened to simply babel (./node_modules/.bin/babel doesn't work on windows IIRC).

Properly written, the script should be:

"build": "rimraf ./build && mkdirp ./build && babel -d ./build ./src"

For this script to work, you will have to install rimraf and mkdirp. You can do this by running:

npm install --save-dev rimraf mkdirp

The --save-dev flag will add rimraf and mkdirp to your package.json's devDependencies section so that they will automatically be installed with future npm installs.

like image 59
RyanZim Avatar answered Oct 10 '22 07:10

RyanZim


Use rd /s /q "folder name" instead of rm -rf "folder name"

like image 30
Yedhrab Avatar answered Oct 10 '22 08:10

Yedhrab


In order to run bash commands on Windows you need to install Bash complied for Windows. Install Cygwin and add bin directory to you PATH variable.

like image 4
deathangel908 Avatar answered Oct 10 '22 08:10

deathangel908


Windows 10 does not provide a UNIX shell by default. You'll need the appropriate UNIX utilities (such as rm) and a shell that supports the syntax you specified.

You have a few options:

  • Use the Windows 10 Bash Shell - Recent versions of Windows 10 now provide beta support for running Ubuntu within Windows without requiring a virtual machine.

  • Use Cygwin for development - Cygwin provides a shell of your choice and plenty of UNIX / Linux utilities.

  • Run a Virtual Machine with a Linux Guest - There are many options for running a VM on Windows. You can use Hyper-V, VirtualBox, or VMware Player. For a guest operating system, Ubuntu is a popular choice, but Fedora and Debian are also common alternatives.

like image 3
Ryan Leaf Avatar answered Oct 10 '22 07:10

Ryan Leaf