我正在接管一个现有的项目。它包含一个package.json和Gruntfile文件。根据我已经运行过的指令here
npm install在全局安装grunt-cli之后。
但是,运行grunt会导致
$ 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.使用-v运行会提供回溯:
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)“..(路径)..”已经被我替换了一个长的基本路径,它是项目的根。
经过进一步的研究,compass.js导入了'tmp‘模块
var tmp = require('tmp');谁/什么提供了这个模块?
发布于 2014-08-25 00:52:02
移除node_modules (令我惊讶的是,它处于源代码控制之下)并运行
npm cache clean
npm install解决了这个问题。
发布于 2019-07-21 18:02:26
从npm@5开始,npm缓存会自我修复损坏问题,并保证从缓存中提取的数据是有效的。如果您希望确保所有内容都是一致的,请改用npm cache verify。
如果要强制清除,请在运行npm cache verify之后尝试npm cache clean --force
https://stackoverflow.com/questions/25473573
复制相似问题