如何判断npm包是全局还是本地安装的 [英] How to tell if npm package was installed globally or locally

查看:431
本文介绍了如何判断npm包是全局还是本地安装的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在windows7上安装了grunt,node,npm,bower和grunt-cli。

说明我应该用-g标志运行install命令全球。



如何检查安装时是否使用了-g标志。卸载它们并重新安装需要很长时间。 使用列表 使用 -g 标志查看全局安装的所有软件包:

npm list -g



要检查特定软件包是否全局安装,可以提供软件包名称(<$ c
$ b $ p $ npm list -g grunt 在这种情况下,$ c> grunt 您可以使用 grep 来过滤包名称:

$ b

b $ b

npm list -g | grep grunt



来源: https:// docs.npmjs.com/cli/ls


I am installing grunt, node, npm, bower, and grunt-cli on windows7.

The instructions say i should run the install commands with -g flag for global.

How can I check if I used the -g flag when i installed. It will take a lot of time to uninstall them and reinstall.

解决方案

Use the list command with the -g flag to see all packages that are installed globally:

npm list -g

To check if a specific package is installed globally, you can provide the name of package (grunt in this case) as seen below:

npm list -g grunt

Or you can use grep to filter on package names:

npm list -g | grep grunt

Source: https://docs.npmjs.com/cli/ls

这篇关于如何判断npm包是全局还是本地安装的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆