"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
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.
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 install
s.
Use rd /s /q "folder name"
instead of rm -rf "folder name"
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With