我有一个 package.json
文件,其中定义了以下脚本:
“脚本”:{
“测试”:“./node_modules/selenium-cucumber-js/index.js”
}
当我在 linux 或 mac 上运行 npm test
时,此脚本按预期运行。但是在 Windows 上我得到一个错误:
/node_modules/selenium-cucumber-js/index.js
'.'不被识别为内部或外部命令,
可运行的程序或批处理文件。
错误!测试失败。有关更多详细信息,请参见上文。
但是,如果我直接从 cmd 提示符运行命令 ./node_modules/selenium-cucumber-js/index.js
它可以正常工作。如果我尝试通过以“.”开头的 npm 运行任何其他脚本,也会出现同样的问题。我还没有找到任何其他讨论这个问题的线程。
我在 Windows 10 家庭版上运行 npm 版本 5.6.0
。
有谁知道我怎样才能让它工作?
最佳答案
从 npm 5.1 开始
npm config set script-shell "C:\\Program Files (x86)\\git\\bin\\bash.exe"
或(64位安装)
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
请注意,您需要有 git for windows installed .
您可以通过运行以下命令恢复它: npm config delete script-shell
关于windows - 在以句点开头的 Windows 上运行 npm 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50998089/