0

執行命令: 默認任務是concat。Grunt - pkg未定義

grunt -v 

我收到以下錯誤消息:

驗證屬性concat.dist在配置存在...警告:錯誤 在處理模板時發生(沒有定義PKG)。使用 - force 繼續。

我想,pkg是package.json。 我用在Gruntfile.js佔位符

pkg.name 。

這裏有什麼問題?

Gruntfile.js摘錄:

concat: { 
      options: { 
       // define a string to put between each file in the concatenated output 
       separator: ';' 
      }, 
      dist: { 
       // the files to concatenate 
       src: ['www/**/*.js'], 
       // the location of the resulting JS file 
       dest: 'www-built/<%= pkg.name %>.js' 
      } 
     } 

的package.json

{ 
    "name": "myprodpackage", 
    "version": "0.0.9", 
    "devDependencies": { 
    "grunt": "^1.0.1", 
    "grunt-contrib-concat": "^1.0.1", 
    "grunt-contrib-cssmin": "^1.0.2", 
    "grunt-contrib-jshint": "^1.0.0", 
    "grunt-contrib-qunit": "^1.2.0", 
    "grunt-contrib-uglify": "^2.0.0", 
    "grunt-contrib-watch": "^1.0.0" 
    }, 
    "description": "test package", 
    "main": "Gruntfile.js", 
    "dependencies": { 
    "bloodhound": "^1.0.0", 
    "backbone": "^1.3.3", 
    "grunt-contrib-cssmin": "^1.0.2", 
    "grunt-contrib-concat": "^1.0.1", 
    "grunt-contrib-qunit": "^1.2.0", 
    "grunt": "^1.0.1", 
    "grunt-contrib-uglify": "^2.0.0", 
    "gulp-clean-css": "^2.0.13", 
    "grunt-contrib-jshint": "^1.0.0", 
    "grunt-contrib-watch": "^1.0.0", 
    "lodash": "^4.17.2", 
    "gulp-minify": "^0.0.14", 
    "gulp-uglify": "^2.0.0", 
    "jquery": "^3.1.1", 
    "requirejs": "^2.3.2", 
    "respond.js": "^1.4.2", 
    "text": "^2.0.15", 
    "underscore": "^1.8.3" 
    }, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "legends", 
    "license": "ISC" 
} 

回答

1

我懷疑你的Gruntfile缺乏,設置在你的配置一個pkg財產的部分。像這樣的東西在大多數Gruntfile中都很常見。

grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json') 
}); 

增加,物業應該pkg.name一樣什麼是你package.json

+0

Oooooh myyy .....謝謝:-) – Legends