|
|
| 第18行: |
第18行: |
|
| |
|
| == 全局 == | | == 全局 == |
| === 普通用户 ===
| |
| 在 Linux 和 Mac 中,普通用户如何全局安装 npm 包:<br>
| |
| 需要将 npm 包存放在当前用户的主目录 <code>.npm-packages</code> 中
| |
| {{shc|<syntaxhighlight lang="bash">
| |
| mkdir .npm-packages</syntaxhighlight>|kangkk@LAPTOP-S5B1JMCV:~$}}
| |
|
| |
| {{hc|~/.npmrc|<syntaxhighlight lang="javascript">
| |
| prefix=${HOME}/.npm-packages</syntaxhighlight>}}
| |
| {{hc|.bashrc or .bash_profile or .zshrc | <syntaxhighlight lang="bash">
| |
| # 定义npm存放的目录
| |
| NPM_PACKAGES="${HOME}/.npm-packages"
| |
|
| |
| # 确保node可以找到安装的包
| |
| NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
| |
|
| |
| # 确保可以使用安装的二进制应用和man文档
| |
| PATH="$NPM_PACKAGES/bin:$PATH"
| |
| # Unset manpath so we can inherit from /etc/manpath via the `manpath`
| |
| # command
| |
| unset MANPATH # delete if you already modified MANPATH elsewhere in your config
| |
| MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
| |
| </syntaxhighlight>}}
| |
|
| |
| == 参数 == | | == 参数 == |
| {| class="wikitable" | | {| class="wikitable" |