npm软件安装包_npm在哪里安装软件包?

npm软件安装包

Read the npm guide if you are starting out with npm, it’s going to go in a lot of the basic details of it.

如果您从npm入手,请阅读npm指南 ,其中将包含许多基本细节。

When you install a package using npm (or yarn), you can perform 2 types of installation:

使用npm (或yarn )安装软件包时,可以执行两种安装类型:

  • a local install

    本地安装
  • a global install

    全局安装

By default, when you type an npm install command, like:

默认情况下,当您键入npm install命令时,例如:

npm install lodash

the package is installed in the current file tree, under the node_modules subfolder.

该软件包安装在当前文件树的node_modules子文件夹下。

As this happens, npm also adds the lodash entry in the dependencies property of the package.json file present in the current folder.

发生这种情况时, npm还会在当前文件夹中存在的package.json文件dependencies属性中添加lodash条目。

A global installation is performed using the -g flag:

使用-g标志执行全局安装:

npm install -g lodash

When this happens, npm won’t install the package under the local folder, but instead, it will use a global location.

发生这种情况时,npm不会将软件包安装在本地文件夹下,而是使用一个全局位置。

Where, exactly?

到底在哪里?

The npm root -g command will tell you where that exact location is on your machine.

npm root -g命令将告诉您确切位置在您计算机上的哪个位置。

On macOS or Linux this location could be /usr/local/lib/node_modules. On Windows it could be C:\Users\YOU\AppData\Roaming\npm\node_modules

在macOS或Linux上,此位置可能是/usr/local/lib/node_modules 。 在Windows上,可能是C:\Users\YOU\AppData\Roaming\npm\node_modules

If you use nvm to manage Node.js versions, however, that location would differ.

但是,如果使用nvm管理Node.js版本,则该位置将有所不同。

I for example use nvm and my packages location was shown as /Users/flavio/.nvm/versions/node/v8.9.0/lib/node_modules.

例如,我使用nvm ,我的软件包位置显示为/Users/flavio/.nvm/versions/node/v8.9.0/lib/node_modules

翻译自: https://flaviocopes.com/where-npm-install-packages/

npm软件安装包

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值