简体   繁体   中英

Error trying to install grunt

I installed grunt using this code:

npm install -g grunt-cli

When I run grunt --version it returns me the version:

grunt-cli v0.1.13

But when I go to my project's folder and run npm install , it returns me those errors messages:

npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/Applications/XAMPP/xamppfiles/htdocs/grunt/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! System Darwin 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Applications/XAMPP/xamppfiles/htdocs/grunt
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /Applications/XAMPP/xamppfiles/htdocs/grunt/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Applications/XAMPP/xamppfiles/htdocs/grunt/npm-debug.log
npm ERR! not ok code 0

What I'm doing wrong? I just google it for a while and I couldn't find an answer for my question, can someone help me?

npm install reads and installs dependencies from a package.json file and has nothing to do with grunt.

node is telling you that you don't have a package.json file.

Create a package.json by running npm init and then stepping through the process.

To save dependencies to your package.json file, you would then run

npm install grunt --save-dev

where grunt in the above command is an example of a dependency.

Also, you haven't actually installed grunt - you've installed the grunt command line interface whose job is to act as an interface to the local grunt installation. You haven't installed grunt locally yet (from what you've shown).

npm install grunt --save-dev will install it locally for you (and save it as a dependency in your package.json file)

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