簡體   English   中英

咕嚕聲 - 得到“本地Npm模塊”xxx“未找到。它安裝了嗎?“造成這種情況的原因是什么?

[英]grunt - getting “Local Npm module ”xxx“ not found. Is it installed?” What's causing this?

我剛剛收到了一份grunt包的副本,但是我是新手,我很難找到一些事情的答案。 最大的問題是不知道下面的錯誤來自哪里 - 有人能告訴我這是從哪里來的嗎? 這兩個文件都在同一目錄中。

$ 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:

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

您可能沒有在本地安裝必要的軟件包。 嘗試npm installsudo npm install )以確保你這樣做。

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

  1. 刪除node_modules文件夾(或在某處備份)

  2. 然后運行npm install

為了重新開始。

你必須告訴grunt在哪里找到node_modules。 我的Gruntfile以:

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方法)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM