尝试安装grunt时出错

我用这个代码安装了grunt:

npm install -g grunt-cli 

当我运行grunt --version返回给我的版本:

 grunt-cli v0.1.13 

但是,当我去我的项目的文件夹,并运行npm install ,它会返回我的错误消息:

 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 

我做错了什么? 我只是谷歌一段时间,我无法find我的问题的答案,有人可以帮助我吗?

npm installpackage.json文件中读取和安装依赖关系,与grunt无关。

node告诉你,你没有package.json文件。

通过运行npm init创build一个package.json ,然后逐步完成这个过程。

为了将依赖关系保存到你的package.json文件,你将会运行

npm install grunt --save-dev

上面的命令中的grunt是一个依赖项的例子。

另外,你还没有安装grunt – 你已经安装了grunt命令行界面,其作用是作为本地grunt安装的界面。 你还没有安装本地咕噜(从你已经显示)。

npm install grunt --save-dev将在本地安装它(并将其保存为package.json文件的依赖项)