“-g"是什么意思标志在命令“npm install -g <something>"中做什么? [英] what does the &quot;-g&quot; flag do in the command &quot;npm install -g &lt;something&gt;&quot;?

查看:77
本文介绍了“-g"是什么意思标志在命令“npm install -g <something>"中做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注使用 npm install 时使用 -g 标志的示例,但我无法通过帮助系统弄清楚 -g 标志在做什么.

I'm following examples that use the -g flag when using npm install but I can't figure out through the help system what the -g flag is doing.

推荐答案

-g 告诉 npm 安装命名模块,以便全局访问.

-g tells npm to install the named module so that it's accessible globally.

但重要的是要了解 -g 通常仅用于提供命令行实用程序的包,以便它们的可执行组件在系统 PATH 中可用.

But it's important to understand that -g is typically only used for packages that provide command-line utilities so that their executable components are available in the system PATH.

如果您有多个需要相同包的程序,则每个程序都应在本地安装该包.如果你真的想通过全局安装来共享一个已安装的包,你还必须使用 npm link.

If you have multiple programs that require the same package, each program should install the package locally. If you really want to share an installed package by installing it globally, you have to also use npm link.

查看有关全局安装包主题的文档此处.

See the docs on the topic of globally installed packages here.

这篇关于“-g"是什么意思标志在命令“npm install -g <something>"中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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