Reputation: 9
Mocha is installed globally on Windows, but cmd shows "mocha is not an internal or external command, nor is it a runnable program or batch file"
Upvotes: 0
Views: 4570
Reputation: 1238
On installation, the location of mocha.cmd
is not added to path. If you install globally, as @hemanshu suggests, that location is %APPDATA%\npm
. So, you either add that to your path, or (as I do) define an alias; my cmd.exe
shortcut loads a script to set the path to things actually useful in the command line, set environment variables, etc, and in there I have this:
@doskey mocha=%APPDATA%\npm\mocha.cmd
Upvotes: 1
Reputation: 39
Mocha (test framework for Node.js) uses make and on Windows machine, such errors occur a lot. I guess, at the time of execution it's not recognizing the path. So, you can follow any of the 2 below:
1) Install mocha globally(if not done already) so that it works in the regular windows command line:
npm install -g mocha
Then run your tests with mocha path\to\test.js
OR
2) Other way to deal with this is to use Cygwin and ensure that the developer packages for Cygwin are installed.
Read this article, it will help you: https://altamodatech.com/blogs/?p=452
Upvotes: 2