为什么 运行 npm test 结果为:'.'不是内部或外部命令,也不是可运行的程序或批处理文件。?
Why does running npm test result in: '.' is not recognized as an internal or external command, operable program or batch file.?
我安装了以下软件:
- Windows 10
- Git bash (mingw64)
- Node.js v8.7.0
- npm 版本 5.4.2
包:
- 柴 4.4.1
- 摩卡 3.5.0
我有一个示例 mocha 测试,它在实际 运行s 时总是会通过。
我 运行 在 shell 中使用的命令:
npm test
输出:
./node_modules/mocha/bin/_mocha
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Test failed. See above for more details.
出于某种原因,我能够直接运行这个命令:
./node_modules/mocha/bin/_mocha
结果是
Sample Test
√ passes!
1 passing (4ms)
我猜这与在 windows 中使用类似 bash 的 shell 的奇怪之处有关,但我不确定如何解决问题来自这里。
为什么会发生此错误,有没有办法让 'npm test' 正常工作而不必放弃使用此 windows 编程环境?
感谢和问候
这可能不是一个完美的答案,但它以足以继续开发的方式解决了问题:
在我的 package.json 文件中我有:
"test" : "./node_modules/mocha/bin/_mocha"
将其更改为:
"test" : "node ./node_modules/mocha/bin/_mocha"
做到了,所以我可以 运行 npm test 命令正常。
我仍然不确定为什么原始值不起作用,因为 运行将其作为 shell 中的命令工作得很好。
如果有人看到这篇文章并想提供一些见解,我们将不胜感激。
我安装了以下软件:
- Windows 10
- Git bash (mingw64)
- Node.js v8.7.0
- npm 版本 5.4.2
包:
- 柴 4.4.1
- 摩卡 3.5.0
我有一个示例 mocha 测试,它在实际 运行s 时总是会通过。
我 运行 在 shell 中使用的命令:
npm test
输出:
./node_modules/mocha/bin/_mocha
'.' is not recognized as an internal or external command, operable program or batch file. npm ERR! Test failed. See above for more details.
出于某种原因,我能够直接运行这个命令:
./node_modules/mocha/bin/_mocha
结果是
Sample Test
√ passes!
1 passing (4ms)
我猜这与在 windows 中使用类似 bash 的 shell 的奇怪之处有关,但我不确定如何解决问题来自这里。
为什么会发生此错误,有没有办法让 'npm test' 正常工作而不必放弃使用此 windows 编程环境?
感谢和问候
这可能不是一个完美的答案,但它以足以继续开发的方式解决了问题:
在我的 package.json 文件中我有:
"test" : "./node_modules/mocha/bin/_mocha"
将其更改为:
"test" : "node ./node_modules/mocha/bin/_mocha"
做到了,所以我可以 运行 npm test 命令正常。
我仍然不确定为什么原始值不起作用,因为 运行将其作为 shell 中的命令工作得很好。
如果有人看到这篇文章并想提供一些见解,我们将不胜感激。