2017-01-02 132 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標誌。

希望這會有所幫助!