Thursday, July 6, 2017

Stupid mocha stupid error

For reference only: (and generativity)

This needs to be on the internet, because I didn't find it in a search.

I try to run mocha via npm and pass it `-grep` or `-fgrep` and I get this awful error (can you tell how annoyed I am) about "Cannot find module '-e'" and I think something is wrong with npm install BUT NO

$ npm run mocha -- -fgrep "annotation with string content found"
> @atomist/spring-team-handlers@0.5.10 mocha /Users/jessitron/code/atomisthq/spring-team-handlers/.atomist
> mocha --require intelli-espower-loader 'target/ts-built/mocha/**/*.js' "-fgrep" "annotation with string content found"
Error: Cannot find module '-e'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
What that should say is

"Invalid option -fgrep. Try --fgrep"

So when future me finds this by searching the internet next time: Jess, use two dashes before the `grep` or `fgrep` options to mocha.

1 comment:

  1. Bad error messages are one of the single largest productivity drains of developers.

    It seems in this case the root cause was poor command-line parsing.

    ReplyDelete