grunt Cannot find module 'coffee-script'

Eduardo Dennis picture Eduardo Dennis · May 13, 2014 · Viewed 21.1k times · Source

I used the following commands to install a mean stack and create an app:

> sudo npm install -g meanio@latest // Get the mean cmdline
> mean init myApp // create your first app
> cd myApp && npm install // Install dependencies
> grunt // Launch mean

but when I get to the final grunt command I get the error:

module.js:333 throw err; ^ Error: Cannot find module 'coffee-script' at Function.Module._resolveFilename (module.js:331:15) at Function.Module._load (module.js:273:25) at Module.require (module.js:357:17) at require (module.js:373:17) at Object.<anonymous> (/home/eddie/ResFour/node_modules/grunt/lib/grunt.js:16:1)

I've tried various solutions on stackoverflow to no avail:

NodeJS - setting up mean.io cannot find module errors

Cannot find module 'coffee-script'

I also cleared npm cache and reinstalled a few times.

Answer

wilbeibi picture wilbeibi · Jul 7, 2014
  1. Remove node_modules directory.
  2. npm cache clean to empty downloaded temporary dependencies, just in case.
  3. npm install again, and better not to interrupt it while running.

These solved most of these problems for me.