简体   繁体   中英

npm install is not installing grunt js from dependencies

I am trying to automatic all the package installations automatic for developers. So I have both package.json and grunt file in the same directory. I want to do npm install first so that all dependencies will be installed and when developer executes grunt on command line things will be ready. May I know why it is not working. The other thing is may I know the difference between dependency and devdependencies.

{
  "name": "TestProject",
  "version": "0.1.0",
  "description": "this project is for test",
  "main": "index.js",
  "dependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-uglify": "~0.2.7",
    "uglify-js": "~2.4.3",
    "grunt-contrib-watch":"~0.5.3",
    "grunt-contrib-jshint": "~0.7.2",
    "qunit": "~1.11.0"
  },  
  "devDependencies": {
    "grunt": "~0.4.2",
    "qunit": "~1.11.0",
    "grunt-contrib-jshint": "~0.7.2",
    "grunt-contrib-nodeunit": "~0.2.0",
    "grunt-contrib-uglify": "~0.2.2",
    "grunt-contrib-watch": "~0.5.3",
    "grunt-contrib-watch":"~0.5.3"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "BSD-2-Clause"
}

You are probably missing the command-line utility for Grunt.

That can be installed in your shell, using

npm install -g grunt-cli

The CLI is distributed independently from the grunt package or the grunt- plugins. You should include instructions to install grunt-cli globally in the same dev environment setup documentation where you indicate how to set up node , npm , bower , or the like.

Update

If you are so adamant about installing grunt-cli on npm install , I guess one option might be using npm scripts .

Include in your package.json (note: untested)

{
  "postinstall": "npm i -g grunt-cli"
}

I'd discourage this, though. Just install them by hand.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM