为什么 mkdir <path> 在 Windows 中运行 npm 时会失败?



我在Windows上使用Cygwin Bash。当我运行mkdir -p dist/ts时,它可以正常工作。但是,当 package.json中的脚本添加时,例如

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

npm返回以下错误:

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! angular2-google-maps@0.16.0 test1: `mkdir -p dist/ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-google-maps@0.16.0 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:cygwinhomemmauricepintoStartupangular2-google-mapsnpm-debug.log

它是Windows中有文件系统的东西,在使用MKDIR时应使用后斜切。查看本文的最后一段:https://www.windows-commandline.com/create-directory-command-line

使用此:

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

您需要使用两个后拉赫\,因为在这种情况下,它被解释为逃生序列。

最新更新