本文共 1638 字,大约阅读时间需要 5 分钟。
npm软件安装包
Read the if you are starting out with npm, it’s going to go in a lot of the basic details of it.
如果您从npm入手,请阅读 ,其中将包含许多基本细节。
When you install a package using npm
(or ), you can perform 2 types of installation:
使用npm
(或 )安装软件包时,可以执行两种安装类型:
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 present in the current folder.
发生这种情况时, npm
还会在当前文件夹中存在的的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
。
翻译自:
npm软件安装包
转载地址:http://kxqgb.baihongyu.com/