Maclean Pinto
Maclean Pinto

Reputation: 1135

Why does mkdir <path> fails in npm run in Windows?

I am using Cygwin bash on windows. When I run mkdir -p dist/ts it works fine. But when the same is added to a script in package.json like

  "scripts": {
    "test1": "mkdir -p dist/ts "
  }

npm returns the following error:

The syntax of the command is incorrect.

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mmauricepinto\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "test1"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test1: `mkdir -p dist/ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test1 script 'mkdir -p dist/ts'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-google-maps package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     mkdir -p dist/ts
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-google-maps
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-google-maps
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\cygwin\home\mmauricepinto\Startup\angular2-google-maps\npm-debug.log

Upvotes: 1

Views: 1262

Answers (1)

Axel Stone
Axel Stone

Reputation: 1580

It is something with a filesystem in windows where backslashes should be used when using mkdir. Check last paragraph of this article: https://www.windows-commandline.com/create-directory-command-line

Use this:

  "scripts": {
    "test1": "mkdir -p dist\\ts"
  }

You need to use two backslahes \\ becouse it is interpreted as an escape sequence in this case.

Upvotes: 1

Related Questions