码迷,mamicode.com
首页 > 系统相关 > 详细

[Tools] Install npm packages globally without sudo on macOS and Linux

时间:2020-01-27 23:54:07      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:npm   color   ash   github   rect   sha   install   des   class   

1 . Create a directory for global packages
mkdir "${HOME}/.npm-packages"
2. Tell npm where to store globally installed packages
npm config set prefix "${HOME}/.npm-packages"
3. Ensure npm will find installed binaries and man pages

Add the following to your .bashrc/.zshrc:

NPM_PACKAGES="${HOME}/.npm-packages"

export PATH="$PATH:$NPM_PACKAGES/bin"

# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

 

Last:

source ~/.bashrc

 

[Tools] Install npm packages globally without sudo on macOS and Linux

标签:npm   color   ash   github   rect   sha   install   des   class   

原文地址:https://www.cnblogs.com/Answer1215/p/12237014.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!