首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >grunt -未找到"Local Npm模块“xxx。是否已安装?”这是什么原因造成的?

grunt -未找到"Local Npm模块“xxx。是否已安装?”这是什么原因造成的?
EN

Stack Overflow用户
提问于 2014-05-21 02:17:10
回答 3查看 40.8K关注 0票数 43

我刚刚收到了一份grunt包的副本,但我是个新手,在寻找一些问题的答案时遇到了困难。最大的问题是不知道下面的错误是从哪里来的--谁能告诉我这是从哪里来的?这两个文件都在同一个目录中。

代码语言:javascript
复制
$ grunt
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-contrib-cssmin" not found. Is it installed?
>> Local Npm module "grunt-contrib-handlebars" not found. Is it installed?
>> Local Npm module "grunt-contrib-jshint" not found. Is it installed?
>> Local Npm module "grunt-contrib-qunit" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-preprocess" not found. Is it installed?
>> Local Npm module "grunt-wrap" not found. Is it installed?
>> Local Npm module "grunt-debug-task" not found. Is it installed?
Warning: Task "clean" not found.  Use --force to continue.

Aborted due to warning.

$

下面是我的package.json:

代码语言:javascript
复制
{
  "name": "baked-widget",
    "srcDirectory": "./src",
    "srcJavascript": "./src/js",
    "srcCss": "./src/css",
    "srcData": "./src/data",
    "testDirectory": "./test",
    "tgtDirectory": "./build",
    "installDirectory": "../com/public/widgets",
  "version": "4.2.0",
  "devDependencies": {
    "grunt": "~0.4",
    "grunt-contrib-clean": "~0.4.0",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-copy": "~0.5.0",
    "grunt-contrib-cssmin": "~0.9.0",
    "grunt-contrib-handlebars": "~0.6",
    "grunt-contrib-jshint": "~0.8",
    "grunt-contrib-uglify": "~0.3",
    "grunt-contrib-qunit": "~0.4",
    "grunt-contrib-watch": "~0.5",
    "grunt-preprocess": "~4.0",
    "grunt-wrap": "~0.3",
    "grunt-debug-task": "~0.1.4"
  }
}
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-05-21 02:41:33

您可能还没有在本地安装所需的包。尝试npm install (sudo npm install)以确保您做到了这一点。

票数 65
EN

Stack Overflow用户

发布于 2016-04-15 23:55:39

如果接受的答案不起作用,并且您有一个正确的package.json文件,您可以:

  1. 删除node_modules文件夹(或将其备份到某个位置)
  2. ,然后运行npm install

为了有一个新的开始。

票数 12
EN

Stack Overflow用户

发布于 2018-07-27 16:39:59

你得告诉格鲁特哪里能找到node_modules。我的Gruntfile以:

代码语言:javascript
复制
module.exports = function (grunt) {
    // Tell grunt where to find node_modules
    grunt.file.setBase('../../../../../');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-hub');

在我的例子中,node_modules文件夹比Gruntfile高5级(看看setBase方法)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23767122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档