安裝咕噥-它是否安裝?

[英]Installing grunt - did it install or not?


I tried installing grunt with npm install grunt but I'm not clear if grunt installed or not:

我嘗試用npm安裝grunt來安裝grunt,但是我不清楚grunt是否已經安裝:

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

e.g.

如。

$ grunt
-bash: grunt: command not found

3 个解决方案

#1


2  

You installed it locally in the directory that you run the install command. You'll have to install it globally with the -g flag. In the grunt web they recomend to install grunt-cli. npm install -g grunt-cli Depending on how you installed node you may want to add sudo to that command: sudo npm install -g grunt-cli

您在運行install命令的目錄中本地安裝了它。您必須使用-g標志在全局安裝它。在grunt網絡中,他們重新安裝了grunt-cli。npm安裝-g grunt-cli取決於您如何安裝節點,您可能希望向該命令添加sudo: sudo npm安裝-g grunt-cli

#2


1  

When you run npm install, the package is placed in the nearest node_modules directory, travelling up the directory tree.

當您運行npm安裝時,包被放置在最近的node_modules目錄中,沿着目錄樹運行。

So, ./node_modules is the first candidate, ../node_modules gets checked next, ../../node_modules next and so on, until one is found.

所以。/node_modules是第一個候選者。/node_modules后面會檢查……/node_modules,直到找到一個。

To run a program installed in the nearest local node_modules, you can use npm bin, which resolves to the appropriate path:

要運行在最近的本地node_modules中的程序,可以使用npm bin,它解析為合適的路徑:

$(npm bin)/grunt

This is the same as running (assuming node_modules in current working directory):

這與運行相同(假設當前工作目錄中的node_modules):

./node_modules/.bin/grunt

If you want to install grunt system-wide, and run it without any of this ceremony, run npm install -g

如果您想要在整個系統范圍內安裝grunt,並在沒有任何這種儀式的情況下運行它,請運行npm安裝-g

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

Note, however, that this enforces a single version of grunt across all of your projects, since they all share the same instance.

但是,請注意,這會在所有項目中強制執行一個單一版本的grunt,因為它們都共享同一個實例。

#3


0  

You can use the following command to see if grunt is installed:

您可以使用以下命令查看grunt是否已安裝:

npm list grunt

If you are installing your packages globally using install -g, then modify the command to use the -g flag:

如果您正在使用install -g在全球安裝包,那么請修改命令以使用-g標志:

npm list -g grunt

To see all top-level installed packages, use:

要查看所有頂級安裝包,請使用:

npm list --depth=0

Note that you can also use the -g flag for the above command as well.

注意,您還可以為上面的命令使用-g標志。

Hope this helps!

希望這可以幫助!


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2017/01/02/72a11d5e24b2a9e527197ed77ce7b97f.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com