Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZach Freitag
20,341 PointsError: "test": "mocha --reporter nyan"
I'm receiving this: Error: Cannot find module './options'
Terminal:
Zachs-MacBook-Pro:start zfreitag34$ npm test
> workspace@1.0.0 test /Users/zfreitag34/Desktop/Treehouse/Unit-Testing/4-next-steps/1-changing-mochas-reporter/star
t
> mocha --reporter nyan
module.js:557
throw err;
^
Error: Cannot find module './options'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/zfreitag34/Desktop/Treehouse/Unit-Testing/4-next-steps/1-changing-mochas-reporter/
start/node_modules/.bin/mocha:11:16)
at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
npm ERR! Test failed. See above for more details.
package.json
{
"name": "workspace",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {
"chai": "^3.5.0"
},
"devDependencies": {
"mocha": "^2.4.5"
},
"scripts": {
"test": "mocha --reporter nyan"
},
"author": "",
"license": "ISC"
}
main_test.js
var expect = require('chai').expect;
// Test suite
describe('Mocha', function () {
//Test spec / unit test
it('should run our tests using npm', function () {
expect(true).to.be.ok;
});
});
After following the video I'm confused with this error.
Best answer gets points =)
Cheers!
2 Answers
Chris Underwood
Full Stack JavaScript Techdegree Student 19,916 PointsPossible fixes for you here.
https://github.com/mochajs/mocha/issues/2582
I also want to add for anyone that wants to try out the two word titles styles like landing strip, you just use the first name such as landing and it will work.
Best,
Chris
Stephen Thomas
3,932 PointsI had similar issue where running mocha from the command line was fine (because I installed with -g option to make it global) but didn't work when using npm test. So the problem seems to be the path to mocha is not working for some
"scripts": { "test": "./node_modules/mocha/bin/mocha test" },