如何将 Powershell 命令添加到 NPM 脚本?

How to add Powershell commands to an NPM script?

这适用于 Powershell 命令行:

C:\rootProject\> copy ZZZ.js -destination ZZZXXX.js

但这行不通:

package.json

"scripts": {
  "copy-script": "copy ZZZ.js -destination ZZZXXX.js"
}

运行 脚本:

C:\rootProject\> npm run copy-script

错误

The syntax of the command is incorrect.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-module-imports@1.0.0 test-copy: `copy ZZZ.js -destination ZZZXXX.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-module-imports@1.0.0 test-copy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Roaming\npm-cache\_logs19-11-29T09_29_59_261Z-debug.log

脚本中的命令前需要powershell项。

package.json

"scripts": {
  "copy-script": "powershell copy ZZZ.js -destination ZZZXXX.js"
}

现在可以使用了:

C:\rootProject\> npm run copy-script