【问题标题】:Can't get Node.JS to install on Mac issues with $PATH使用 $PATH 无法在 Mac 上安装 Node.JS
【发布时间】:2018-06-23 21:36:26
【问题描述】:

我正在尝试推送到 Heroku,但应用程序被拒绝 Webpacker requires Node.js >= 6.0.0 and you are using 0.10.30。我刚刚完成了 node.js 的全新安装,它应该在我的路径 /usr/local/bin 上。

我的路径在下面,这对我来说有点疯狂,但我可以看到 /usr/local/bin 在那里。我哪里错了?

Simons-MBP:~ Simon$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/Simon/.rvm/gems/ruby-2.4.0/bin:/Users/Simon/.rvm/gems/ruby-2.4.0@global/bin:/Users/Simon/.rvm/rubies/ruby-2.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/Simon/.rvm/bin

现在已经通过 Homebrew 安装了节点:

Simons-MBP:gourmet_coffee Simon$ brew link node
Linking /usr/local/Cellar/node/9.4.0... 7 symlinks created
Simons-MBP:gourmet_coffee Simon$ node --version
v9.4.0

Simons-MBP:~ Simon$ node --version
v9.4.0
Simons-MBP:~ Simon$ sudo chown -R $USER /usr/local
Password:
Simons-MBP:~ Simon$ brew link --overwrite node
Warning: Already linked: /usr/local/Cellar/node/9.4.0
To relink: brew unlink node && brew link node
Simons-MBP:~ Simon$ brew unlink node && brew link node
Unlinking /usr/local/Cellar/node/9.4.0... 7 symlinks removed
Linking /usr/local/Cellar/node/9.4.0... 7 symlinks created

但是,我在推送到 Heroku 时仍然遭到同样的拒绝

我应该将/usr/local/Cellar 添加到我的$PATH 吗?

【问题讨论】:

    标签: ruby-on-rails node.js heroku path


    【解决方案1】:

    尝试从 brew 安装:

    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    $ brew update
    $ brew doctor
    

    之后,将 brew 位置添加到 .bash_profile 中的 $PATH:

    $ export PATH="/usr/local/bin:$PATH"
    

    搜索并重新安装特定版本(如果brew无法搜索节点,只需运行brew install node):

    $ brew search node
    $ brew unlink node
    $ brew install node@6
    $ brew link node@6
    

    查看您当前的节点版本:

    $ node --version
    

    【讨论】:

    • 好的,所以就这样做了,但出现以下错误Error: The 'brew link' step did not complete successfully The formula built, but is not symlinked into /usr/local 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
    • @SimonCooper 用于覆盖:sudo chown -R $USER /usr/localbrew link --overwrite node 之后
    • @SimonCooper 好的,第一种方式:brew link -n node 并手动删除冲突文件,然后再次尝试链接节点。
    • Simons-MBP:gourmet_coffee Simon$ brew link -n node Warning: Already linked: /usr/local/Cellar/node/9.4.0 这里显然有其他事情发生。
    • 我目前正在运行 Sierra
    猜你喜欢
    • 2011-07-20
    • 2012-09-24
    • 2019-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 2021-01-06
    • 2017-07-20
    相关资源
    最近更新 更多