[关闭]
@buoge 2017-12-22T17:53:26.000000Z 字数 1704 阅读 946

nodejs 安装配置问题汇总

善用佳软


  1. 1.ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. 2.brew安装node
  3. 首先更新brew,使其在最新版本,代码如下:
  4. $ brew update
  5. 3.确保brew是安全可靠的,代码如下:
  6. $ brew doctor
  1. 将可能导致如下情况,可针对性逐条处理,处理完成放可完成下一步:
  2. Warning: Some directories in /usr/local/share/man aren't writable.
  3. This can happen if you "sudo make install" software that isn't managed
  4. by Homebrew. If a brew tries to add locale information to one of these
  5. directories, then the install will fail during the link step.
  6. You should probably sudo chown -R $(whoami) them:
  7. /usr/local/share/man/man5
  8. /usr/local/share/man/man7
  9. brew的位置添加到$PATH环境变量中,并保存bash或者profile文件;
  10. export PATH="/usr/local/bin:$PATH"
  1. 当处理完上述问题后,来处理brewnode关系
  2. 若在上文中出现,如下错误信息:
  3. Warning: You have unlinked kegs in your Cellar
  4. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
  5. those kegs to fail to run properly once built. Run brew link on these:
  6. node
  7. 则需要如下操作:
  8. 清理brewlink
  9. $ brew cleanup
  10. 删除node文件,完全卸载nodenpm
  11. sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
  12. 或者是
  13. sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
  14. 或者是下面这样:
  15. 1.在/usr/local/lib目录下,删除任何与node node_modules有关的目录;
  16. 2.在/usr/local/include 目录下,删除任何与node node_modules有关的目录;
  17. 3.如果你是通过**brew install node**安装的node,则在终端执行**brew uninstall node** ,并在home目录下查找 **local** 或**lib** **include**文件夹,删除任何与**node** **node_modules**有关的目录;
  18. 4.在**/usr/local/bin**目录下,删除任何与 **node** 执行文件;
  19. 5.最后下载 **nvm** ,跟随它的介绍安装node。当然,你也可以通过**npm**来安装最新版本的Node
  20. 通过brew安装nodenpm
  1. brew link node
  2. brew uninstall node
  3. brew install node
  4. 测试Nodenpm安装是否成功,安装Grunt
  5. npm install -g grunt-cli
  6. 如果安装成功,那么恭喜你nodenpmgrunt均安装成功。若出现问题,请回顾前面内容

原文链接:http://www.jianshu.com/p/20ea93641bda

## 安装 http-server

npm install http-server -g

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注