错误:无法找到模块' time-grunt'

时间:2016-01-23 17:07:32

标签: node.js gruntjs npm

我已使用以下命令为项目设置了所有内容:

 sudo npm install -g grunt-cli
 sudo npm install grunt --save-dev
 sudo npm install grunt-contrib-jshint --save-dev
 sudo npm install jshint-stylish --save-dev
 sudo npm install time-grunt --save-dev
 sudo npm install jit-grunt --save-dev

这是我的package.json文件

 {
    "name": "Project1",
    "private": true,
    "devDependencies": {
       "grunt": "^0.4.5",
       "grunt-contrib-jshint": "^0.12.0",
       "jit-grunt": "^0.9.1",
       "jshint-stylish": "^2.1.0",
       "time-grunt": "^1.3.0"
   },
    "engines": {
      "node": ">=0.10.0"
     }
   }

当我跑“咕噜咕噜”时命令它给出以下错误:

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

    Aborted due to warnings.

1 个答案:

答案 0 :(得分:1)

您需要在依赖项中添加“time-grunt”,而不是在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",

  }
}