Grunt failed ", cannot find module 'tmp'"

I am engaged in an existing project. It contains the package.json file and the Gruntfile. Following the instructions here, I ran

npm install 

after installing grunt-cli worldwide.

However, running grunt's results

 $ grunt --env=production Loading "compass.js" tasks...ERROR >> Error: Cannot find module 'tmp' Warning: Task "compass" not found. Use --force to continue. Aborted due to warnings. 

Running with -v gives a trace:

 Loading "compass.js" tasks...ERROR >> Error: Cannot find module 'tmp' >> at Function.Module._resolveFilename (module.js:338:15) >> at Function.Module._load (module.js:280:25) >> at Module.require (module.js:364:17) >> at require (module.js:380:17) >> at Object.exports.init (/..(path)../node_modules/grunt-contrib-compass/tasks/lib/compass.js:4:13) >> at Object.module.exports (/..(path)../node_modules/grunt-contrib-compass/tasks/compass.js:12:42) >> at loadTask (/..(path)../node_modules/grunt/lib/grunt/task.js:325:10) >> at /..(path)../node_modules/grunt/lib/grunt/task.js:361:7 >> at Array.forEach (native) >> at loadTasks (/..(path)../node_modules/grunt/lib/grunt/task.js:360:11) 

".. (path) .." was inserted by me, replacing the long base path, this is the root of the project.

After some further research, compass.js imports the 'tmp' module

  var tmp = require('tmp'); 

Who / what provides this module?

+6
source share
2 answers

Removing node_modules (which was under source control, to my surprise) and works

 npm cache clean npm install 

solved this problem.

+7
source

Starting with npm @ 5, the npm cache is self-healing from corruption problems, and the data retrieved from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use npm cache verify .

If you want to force a clean, try cleaning npm cache clean --force then run npm cache verify npm cache clean --force

0
source

Source: https://habr.com/ru/post/1201035/


All Articles