错误:无法find模块的时间咕噜声

我尝试安装时间咕噜本地和全球,清除npmcaching,更新npm,但没有什么帮助。 我得到:

Loading "Gruntfile.js" tasks...ERROR Error: Cannot find module 'time-grunt' Warning: Task "default" not found. Use --force to continue. 

我的版本od包:节点:'0.10.31',npm:'1.4.23'

运行后:npm install –save-dev在package.json状态下的时间咕噜声:

 "devDependencies": { "grunt": "^0.4.5", ... "time-grunt": "^1.0.0" } 

这是我的grunfile.js的一部分:

 module.exports = function( grunt ) { require('time-grunt')(grunt); grunt.initConfig({ // grunt tasks here }); // load tasks here // register task here } 

其他咕噜任务运行没有错误。

我不明白什么是错的。

我怎样才能正确地testing通过命令行安装时间咕噜?

您需要将其添加到依赖关系中,而不是在devDependencies中。 这样你就不需要另外运行$ npm install --save-dev time-grunt

 { "name": "grunt-build", "version": "0.1.0", "private": true, "dependencies": { "time-grunt": "^1.3.0" }, "devDependencies": { "grunt": "^0.4.5", "grunt-contrib-clean": "~0.7.0", "grunt-contrib-compress": "~0.5.0", "grunt-contrib-concat": "~0.5.0", "grunt-contrib-copy": "^0.8.0", "grunt-contrib-uglify": "~0.5.0", "grunt-remove-logging": "~0.2.0" } } 

使用npm installsudo npm install在package.json文件夹中

我最终手动安装所有grunt依赖项。

 npm install time-grunt npm install load-grunt-config 

然后在这里列出所有的模块:

在这里输入图像描述

注意:您可以在npm install中一次性npm install上面的照片中的所有依赖项。

最后,我运行了grunt命令,它工作了!