【问题标题】:Error: Cannot find module 'time-grunt'错误:找不到模块'time-grunt'
【发布时间】:2016-04-30 05:04:25
【问题描述】:

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

 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"
     }
   }

当我运行“grunt”命令时,它会出现以下错误:

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

    Aborted due to warnings.

【问题讨论】:

  • 你的 Gruntfile.js 中有什么...确保你正在加载 time-grunt
  • 你有文件夹node_modules/time-grunt 吗?
  • 您是否在 Gruntfile.js 中加载任务?
  • 谢谢大家。我在错误的路径上运行“咕噜”。现在效果很好。
  • 你应该在什么路径下运行“grunt”?

标签: node.js gruntjs npm


【解决方案1】:

您需要在依赖项中而不是在 devDependencies 中添加“time-grunt”。这样你就不需要单独运行 $ 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",

  }
}

【讨论】:

    猜你喜欢
    • 2015-03-07
    • 2013-11-22
    • 2015-04-07
    • 1970-01-01
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-16
    相关资源
    最近更新 更多