在命令提示符中无法识别双点斜杠-正在运行npm命令



我的lerna项目包.json中有以下内容:

{
"scripts": {
"build": "../../node_modules/.bin/tsc"
}
}

当在Windowsbash.exe上运行此程序时,我会得到

'..' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-package@1.0.0 build: `../../node_modules/.bin/tsc`

我尝试过:"build": ""../../node_modules/.bin/tsc"",但没有成功。我希望这个命令能在Windows和Mac上运行。我该如何做到这一点?

我在Windows上使用Git Bash,有一天我运行一个npm脚本时出现了这个问题。默认情况下,在Windows上,npm使用cmd.exe运行脚本,该脚本不理解点斜杠表示法。

对我来说,解决方案是将npm设置为在bash中运行脚本。

对于64位:

npm config set script-shell "C:\Program Files\git\bin\bash.exe"

对于32位:

npm config set script-shell "C:\Program Files (x86)\git\bin\bash.exe"  

或者,我相信git for windows安装程序可以将unix功能添加到命令提示符中,但我没有对此进行测试,因为npm config set命令可以满足我的需要。

最新更新