昨晚在更新node 10.12
到 node 14
的时候 更新之后就报下面的错误,
dyld: initializer function 0x0 not in mapped image for /usr/local/bin/node
一顿折腾无果,就决定删除重装node
一、删除 node和相关缓存
sudo npm cache clean -f
sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d
二、安装
brew install node
安装之后发现 安装的是最新版,而不是最新稳定版,就考虑安装指定版本的node
brew install node@12
执行之后控制台报下面提示
Warning: node@12 is keg-only and must be linked with --force
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node@12/bin:$PATH"' >> ~/.bash_profile
于是终端继续执行:
echo 'export PATH="/usr/local/opt/node@12/bin:$PATH"' >> ~/.bash_profile
之后刷新 bash
文件
source .bash_profile
最后执行
node -v
npm -v
安装成功,最后安装yarn
npm i -g yarn //直接全局安装
网友评论