Legends Legends - 1 year ago 158
Node.js Question

Grunt - pkg is not defined

Executing the command:
Default task is concat.

grunt -v

I get the following Error message:

Verifying property concat.dist exists in config...Warning: An error
occurred while processing a template (pkg is not defined). Use --force
to continue.

I guess, pkg is the package.json.
I use the placeholder

in the Gruntfile.js.

What is the problem here?

Gruntfile.js excerpt:

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'


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

Answer Source

I suspect your Gruntfile is lacking a section that sets a pkg property in your config. Something like this is commonly found in most Gruntfile's.

  pkg: grunt.file.readJSON('package.json')

Adding that property should make pkg.name the same as what is in your package.json.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download