2017-01-02 127 views
2

我尝试安装咕噜与npm install grunt但如果安装grunt与否我不清楚:安装grunt - 安装与否?

$ npm install grunt 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree. 
npm WARN [email protected] No repository field. 
npm WARN [email protected] No license field. 

例如

$ grunt 
-bash: grunt: command not found 

回答

2

您在本地将其安装在运行安装命令的目录中。 您必须使用-g标志全局安装它。 在咕web网络中,他们推荐安装grunt-cli。 npm install -g grunt-cli 取决于你如何安装,你可能需要添加sudo到命令节: sudo npm install -g grunt-cli

1

当您运行npm install,包被放置在最近的node_modules目录,行驶了目录树。

所以,./node_modules是第一候选,../node_modules被选中下一个,下一个../../node_modules等,直到找到一个。

运行安装在当地就近node_modules一个程序,你可以使用npm bin,其解析为相应的路径:

$(npm bin)/grunt 

这是一样的运行(在当前工作目录中,如果node_modules):

./node_modules/.bin/grunt 

如果你想安装grunt系统范围内,且无任何这个仪式的运行,运行npm install -g

npm install -g grunt-cli 
grunt # run without prefix 

但是,请注意,由于它们全部共享相同的实例,因此跨所有项目实施单一版本grunt

0

您可以使用下面的命令来查看是否grunt安装:

npm list grunt 

如果是安装在全球使用install -g你的包,然后修改使用-g标志命令:

npm list -g grunt 

要查看所有顶级安装包,请使用:

npm list --depth=0 

请注意,您也可以使用上述命令的-g标志。

希望这会有所帮助!