我在windows上运行npm并且想在运行脚本中使用&style并行操作但是在cmd中并行运行在我的package.json文件中有点乱 - 我想写 -
脚本:{"go":"cmd1&cmd2"}
但是npm执行cmd.exe下的脚本,该脚本不知道; 我可以将其更改为脚本:{"go":"bats/bat1.bat")其中bat1.bat是一个cmd bat文件,它使用windows样式调用或启动命令来并行运行命令.哪个有效,但给了我一个仅适用于Windows的脚本
如果我可以让npm在bash克隆或cygwin下运行脚本我会尝试配置:{"shell":"bash"}但是仍然运行cmd.exe会简单得多
有没有办法告诉npm使用特定的shell(而不是cmd.exe)运行脚本?
这适用于 Powershell 命令行:
C:\rootProject\> copy ZZZ.js -destination ZZZXXX.js
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
包.json
"scripts": {
"copy-script": "copy ZZZ.js -destination ZZZXXX.js"
}
Run Code Online (Sandbox Code Playgroud)
运行脚本:
C:\rootProject\> npm run copy-script
Run Code Online (Sandbox Code Playgroud)
错误
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 …Run Code Online (Sandbox Code Playgroud) ...我为节点项目的package.json编写了一些脚本。当我在脚本中使用某些语法时,例如 BUILD_PATH= ,我只能在 WLS 命令行 (Linux) 上运行此 npm 脚本,但在 Windows 中与 bash 一起使用时,它会引发错误。我想知道是否有任何工具可以在 Windows 和 Linux 中运行这样的脚本?
示例:来自我的 package.json
"scripts":
{"build": "BUILD_PATH=../server/public react-scripts build"}
Run Code Online (Sandbox Code Playgroud)
当我使用 Linux 命令行 (WSL) 执行该命令时,一切顺利。但对于 Windows,它会抛出错误。
我知道这个命令在 Windows 中相当于什么。但我想知道有一个工具或包可以自动执行此操作。