17
"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
Ryan Leaf
  • 1,025
  • 8
  • 7
Ghayyour Ahmed Butt
  • 383
  • 1
  • 2
  • 12
  • 6
    Before I got a Mac, I did all of my command-line type development in the Git Bash which emulates a UNIX style terminal for your environment – m_callens Jan 03 '17 at 20:35

6 Answers6

23

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.

RyanZim
  • 6,609
  • 1
  • 27
  • 43
6

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

yEmreAk.com
  • 3,278
  • 2
  • 18
  • 37
4

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.

deathangel908
  • 8,601
  • 8
  • 47
  • 81
3

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.

Ryan Leaf
  • 1,025
  • 8
  • 7
0

Not to Bash, but in Windows you can use the built-in remove directory (rd) command:

RD /S /Q "folder-name"
Sting
  • 333
  • 2
  • 11
0

Follow this link: https://learn.microsoft.com/en-us/windows/nodejs/setup-on-wsl2 You will install a linux client for windows, and then instal node.js for that client and you can run rm commands easily

Amin Keshavarzian
  • 3,646
  • 1
  • 37
  • 38