How to run Mocha tests on windows node.js ( Error: Cannot find module 'C:\cygdrive\c\Users )

Best way I've been able to do it is to first install mocha in the directory as a dev dependency (i.e: npm install mocha --save-dev). Then in the npm test command inside package.json, use "test": "mocha". This way, you can easily run npm test in CLI for standardization. You can now either setup your tests in a test/ directory or have a simple test.js file in case you only have a few tests to run. Also, don't forget to have a mocha.opts file with your options. This should work, especially if you're using Git Bash (I tried on windows CMD and it works too!).


You can configure the npm test command inside the package.json file to run mocha using the syntax below.

  "scripts": {
      "test": "node node_modules/mocha/bin/mocha --recursive"
  },