Error: Cannot find module 'time-grunt'

女生的网名这么多〃 提交于 2019-12-05 11:57:52

问题


I try install time-grunt local and global, clear npm cache, update npm, but nothing helps. I get:

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

My version od packages: node: '0.10.31', npm: '1.4.23'

After run: npm install --save-dev time-grunt in package.json state:

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

This is part of my grunfile.js:

module.exports = function( grunt ) {
     require('time-grunt')(grunt);

     grunt.initConfig({
     // grunt tasks here
     });
     // load tasks here
     // register task here
}

Other grunt tasks runing without error.

I not understand what is wrong.

How I can test correctly installation of time-grunt by command line?


回答1:


You need to add it inside dependencies and not within devDependencies. This way you don't need to separately run $ 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"
  }
}



回答2:


use npm install or sudo npm install in the folder with package.json




回答3:


I ended up installing all grunt dependencies manually.

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

and then all modules listed here:

Note: you can install all of the dependencies in the photo above in one go with npm install.

Finally I ran the grunt command and it worked!



来源:https://stackoverflow.com/questions/27858546/error-cannot-find-module-time-grunt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!