1. 发现安装不上,可能是之前npm与cnpm搞混了
2. 更新npm的版本(原先是node -v8.9.4 npm -v5.6.0),使用npm install @latest 后,node与npm版本不匹配。想着返回npm的版本,无法实现。删除npm,此时只有node -v,而无npm -v,更完蛋。
3. 更新node -v也无法实现,删除node也无法彻底删除。到处找彻底删除node的方法。还是删不掉。
4. 使用brew update; brew link node; brew uninstall node; brew install node
Warning: node 16.6.2 is already installed, it's just not linked.
To link this version, run:
brew link node
5. brew link node
Linking /usr/local/Cellar/node/16.6.2...
Error: Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
6. 使用rm ‘/usr/local/bin/node’;再brew link node
Error: Could not symlink include/node/common.gypi
Target /usr/local/include/node/common.gypi
already exists. You may want to remove it:
rm '/usr/local/include/node/common.gypi'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
实在解决不了。使用pip install node
7. pip install node
又不行。又使用brew install node
Warning: node 16.6.2 is already installed, it's just not linked.
To link this version, run:
brew link node
8. brew link node
Linking /usr/local/Cellar/node/16.6.2...
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.
9. 重点:Homebrew的/usr/local/share/… is not writable.文件权限问题
链接:https://blog.csdn.net/victor_barnett/article/details/79373413
10. 使用sudo chown -R whoami
:admin /usr/local/share,终于好了。
Linking /usr/local/Cellar/node/16.6.2... 7 symlinks created.
11.结果发现原先一直默认的node版本没有改过来,查了一下,原来有个叫nvm的东西。使用nvm install stable,即可安装并默认使用稳定版,搞定!!
https://www.cnblogs.com/gaozejie/p/10689742.html
12. 此时就可以愉快地install cordova啦
https://www.jianshu.com/p/249d4998aa0c