【问题标题】:Grunt "Gruntfile.js" tasks...ERRORGrunt“Gruntfile.js”任务...错误
【发布时间】:2016-03-02 08:44:26
【问题描述】:
    pm WARN EPACKAGEJSON partnerportal@0.0.0 No description
    npm WARN EPACKAGEJSON partnerportal@0.0.0 No license field.
    >> Local Npm module "grunt-autoprefixer" not found. Is it installed?
    >> Local Npm module "grunt-concurrent" not found. Is it installed?
    >> Local Npm module "grunt-contrib-concat" not found. Is it installed?
    >> Local Npm module "grunt-contrib-connect" not found. Is it installed?
    >> Local Npm module "grunt-contrib-htmlmin" not found. Is it installed?
    >> Local Npm module "grunt-contrib-jshint" not found. Is it installed?
    >> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
    >> Local Npm module "grunt-contrib-watch" not found. Is it installed?
    >> Local Npm module "grunt-filerev" not found. Is it installed?
    >> Local Npm module "grunt-google-cdn" not found. Is it installed?
    >> Local Npm module "grunt-karma" not found. Is it installed?
    >> Local Npm module "grunt-newer" not found. Is it installed?
    >> Local Npm module "grunt-ng-annotate" not found. Is it installed?
    >> Local Npm module "grunt-svgmin" not found. Is it installed?
    >> Local Npm module "grunt-usemin" not found. Is it installed?
    >> Local Npm module "grunt-wiredep" not found. Is it installed?
    Loading "Gruntfile.js" tasks...ERROR
    >> Error: Cannot find module 'time-grunt'

NPMgrunt 的新手。不确定到底发生了什么?任何想法如何调试?安装了 NPMBOWER

【问题讨论】:

  • 似乎grunt 正在尝试加载time-grunt,但是在node_modules 中找不到该包。您可以做两件事:(1)如果您有一个 package.json 文件,它可能指定了许多依赖项,因此只需在同一目录中运行 npm install 即可将这些依赖项下载到您的node_modules 目录; (2)安装个别模块,如time-grunt,可以做npm install time-grunt --save-dev
  • 你的 Gruntfile.js 中有什么?
  • 更新了我有问题的 Gruntfile.js
  • @HunanRostomyan 我更新了脚本来执行 nam install time-grunt,现在它在抱怨 > 错误:找不到模块 'jshint-stylish'。它是否必须对路径做任何事情,因为没有加载任何 nam 模块。不知道路径是否设置正确?
  • @upagna 注意require('load-grunt-tasks')(grunt); 这一行。这样做是在 package.json 中查找声明的依赖项。如果你不做npm install,那些依赖可能会丢失,所以 grunt 将无法找到它们。首先,丢失的是time-grunt 插件,现在是jshint-stylish。您只需要通过运行npm install 来安装所有依赖项。

标签: javascript node.js amazon-ec2 gruntjs npm


【解决方案1】:

我认为,在运行 grunt 之前,您没有运行 npm install 来为您的项目安装所有软件包。在正常情况下,构建一个 Grunt App。我们应该按照以下步骤运行:

安装 NPM 包。

cd to_root_project_path

npm install

安装 Bower 包

bower install

最后,运行 grunt tast

【讨论】:

    【解决方案2】:

    有时 sudo 和 npm install grunt 也可以解决问题

    sudo npm install grunt

    【讨论】:

    • 这可能会解决问题,也可能不会,但它并不能真正帮助提问者了解正在发生的事情或如何调试,这是手头的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 2017-09-08
    • 1970-01-01
    • 2015-02-13
    • 2018-11-18
    相关资源
    最近更新 更多