【问题标题】:The best way to install node.js on a Mac?在 Mac 上安装 node.js 的最佳方式是什么?
【发布时间】:2015-12-22 17:54:16
【问题描述】:

Homebrew 和 Node 下载页面将 node.js 安装在明显冲突的不同位置。如果同时使用这两个位置,Brew 会在 'brew doctor' 之后抱怨。

那么,有没有一种将节点放在我的 Mac(Yosemite 10.10.5)上的首选方法。

这就是我现在尝试通过 brew 安装节点时得到的结果。

node-4.1.0 already installed, it's just not linked
DONs-iMac:Erlang-Elixir donfox1$ brew link node
Linking /usr/local/Cellar/node/4.1.0... 
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.

【问题讨论】:

    标签: node.js macos


    【解决方案1】:

    您是否尝试过 chmoding 755 /usr/local/share/systemtap/tapset 使其可写?那能治好吗?

    chmod 755 /usr/local/share/systemtap/tapset
    brew link node 
    

    如果它不起作用,也试试这个(可能起作用):

    brew cleanup
    brew link node
    brew uninstall node
    brew install node
    

    【讨论】:

    • 我做了上述,但仍然有同样的问题。磁带上的权限,一个空目录是:drwxr-xr-x 2 root admin 68 Sep 21 16:00 tapset。还是不能写?
    • 好的,然后执行 chmod 777 并在安装完成后恢复为 755。
    • 删除文件夹sudo rm -rf /usr/local/share/systemtap/,卸载节点brew uninstall node,重新安装节点brew install node,创建符号链接brew link node
    【解决方案2】:

    sudo chown -R $USER /usr/local/share/ brew doctor brew install node

    【讨论】:

      【解决方案3】:

      卸载节点: sudo rm -rf /usr/local/share/systemtap/ && brew uninstall node 并使用 brew 安装 nvm - 这样您就可以控制节点版本。 阅读本文:suggested way to install npm with brew

      【讨论】:

        【解决方案4】:

        如果您不确定您现在需要什么版本的节点以及将来可能需要什么版本,我还建议您安装 NVM - 节点版本管理器。
        通过 cURL 下载 nvm 安装脚本:

        curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
        

        确保使用nvm --version 正确安装了 nvm,这应该返回已安装的 nvm 版本。
        安装你想要的 Node.js 版本
        使用nvm install node安装最新版本
        通过nvm use node使用最新版本
        使用nvm install --lts安装最新的 LTS 版本
        通过nvm use --lts使用最新的 LTS 版本

        您也可以查看教程:
        installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu
        Best way to install and use nvm on Mac

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-08-13
          • 2020-10-17
          • 1970-01-01
          • 2012-11-27
          • 2010-11-15
          • 1970-01-01
          • 2018-08-21
          • 2015-09-07
          相关资源
          最近更新 更多