Reputation: 32843
I followed the documentation on grunt site. After executing sudo npm install -g grunt-cli
I got this output
npm http GET https://registry.npmjs.org/grunt-cli
npm http 304 https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/resolve
npm http 304 https://registry.npmjs.org/resolve
npm http 304 https://registry.npmjs.org/findup-sync
npm http 304 https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz
npm http 200 https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
[email protected] /usr/local/lib/node_modules/grunt-cli
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
After this, when I do grunt
I get this message
grunt-cli: The grunt command line interface. (v0.1.11)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started
After this I also followed this link to solve my problem but I still am getting the same error above.
UPDATE
Gruntfile.js
module.exports = function () {
grunt.initConfig({
min: {
dist: {
src: 'file-one.js',
dest: 'file-one.min.js'
}
}
});
}
package.json file
{
"name": "grunt",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.1.11",
"grunt-contrib-jshint": "~0.6.3",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2"
}
}
Upvotes: 1
Views: 4716
Reputation: 161457
You have installed grunt-cli
as a global package, but you also need to install grunt
locally. The grunt-cli
package installs a global command line tool, but that command line tool just tries to load the locally install grunt
module. This is done in order to allow people to have multiple versions of grunt for different projects, you need to have grunt itself installed as a local package in the project you are working on.
From the page you linked to:
Note that installing grunt-cli does not install the Grunt task runner! The job of the Grunt CLI is simple: run the version of Grunt which has been installed next to a Gruntfile. This allows multiple versions of Grunt to be installed on the same machine simultaneously.
So you need to have grunt
as a local dependency in your package.json file, just like any other module, wheres you would not list grunt-cli
in there.
Upvotes: 7