问题描述
我已经安装了以下软件:
I have the following installed:
- Windows 10
- Git bash(mingw64)
- Node.js v8.7.0
- npm版本5.4.2
包装:
- 柴4.4.1
- 摩卡咖啡3.5.0
我有一个示例摩卡测试,它将在实际运行时始终通过.
I have a sample mocha test that will always pass when it actually runs.
我在shell中运行的命令:
The command I'm running in my shell:
npm test
输出:
'.不被识别为内部或外部命令,可操作的程序或批处理文件.npm ERR!测试失败.有关更多详情,请参见上文.
'.' is not recognized as an internal or external command, operable program or batch file. npm ERR! Test failed. See above for more details.
由于某种原因,我可以直接运行此命令:
For some reason I'm able to run this command directly:
./node_modules/mocha/bin/_mocha
会导致
√通过!
1次通过(4毫秒)
我猜想这与在Windows中使用类似bash的shell的怪异有关,但是我不确定如何从这里进行故障排除.
I'm guessing this has something to do with the weirdness of using a bash-like shell inside of windows, however I'm not sure how I can troubleshoot this from here.
为什么会发生此错误,并且有一种方法可以使'npm test'正常工作而不必使用此Windows编程环境而放弃呢?
Why might this error be happening, and is there a way to get 'npm test' to work properly without having to ditch using this windows programming environment?
感谢&问候
推荐答案
这可能不是一个完美的答案,但是它以足以继续开发的方式解决了该问题:
This may not be a perfect answer, but it fixes the issue in a way that is sufficient to continue developing:
在我的package.json文件中:
in my package.json file I had:
"test" : "./node_modules/mocha/bin/_mocha"
将其更改为:
"test" : "node ./node_modules/mocha/bin/_mocha"
做到了,所以我可以很好地运行npm test命令.
Made it so I could run npm test command fine.
我仍然不确定为什么原始值不起作用,因为在shell中将其作为命令运行就可以了.
I'm still unsure as to why the original value would not work since running that as a command in the shell works just fine.
如果有人看到了这一点,并希望提供一些见识,将不胜感激.
If anyone sees this and wants to offer some insight that would be greatly appreciated.
这篇关于为什么运行npm测试会导致:“."无法识别为内部或外部命令,可操作程序或批处理文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!