"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
"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
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.
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.
Use rd /s /q "folder name"
instead of rm -rf "folder name"
Not to Bash, but in Windows you can use the built-in remove directory (rd) command:
RD /S /Q "folder-name"