转载
使用brew 安装node
首先先对 brew 进行检查
brew update
brew doctor
创建目录,并修改权限
因为权限问题,我这里是手动创建的。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
sudo mkdir /usr/local/Cellar
sudo chown -R $(whoami) /usr/local/Cellar
sudo mkdir /usr/local/opt
sudo chown -R $(whoami) /usr/local/opt/
sudo mkdir /usr/local/opt/icu4c
sudo chown -R $(whoami) /usr/local/opt/
sudo mkdir /usr/local/include
sudo chown -R $(whoami) /usr/local/include/
sudo mkdir /usr/local/share
sudo chown -R $(whoami) /usr/local/share
|
然后进行安装
brew link node
brew uninstall node
brew install node
我这里失败了啊
1
2
3
4
5
|
node -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.67.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
zsh: abort node -v
|
1
2
3
4
5
6
7
8
9
|
brew uninstall --force node
brew uninstall icu4c && brew install icu4c
brew unlink icu4c && brew link icu4c --force
# 这里可能会提示设置 ~/.zshrc。 看底部 icu4c ~/.zshrc 这个模块
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
# 如果执行了上面那条命令,需要更新资源文件
source ~/.zshrc
brew install node
|
icu4c ~/.zshrc
If you need to have icu4c first in your PATH run:
1
2
|
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc
|
For compilers to find icu4c you may need to set:
1
2
|
export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"
|
常用命令
npm install <module> //安装
npm uninstall <module> //卸载
npm search <module> //搜索
npm update <module> //更新
npm
npm 是node.js自带的功能。