如何brew安装特定版本的Node?

时间:2017-06-28 13:20:41

标签: javascript node.js homebrew

例如,我想安装7.9或7.10,但由于webpack node-sass破坏错误而希望避免使用Node。

当我运行brew search node时,这就是我所看到的:

  

❯brew搜索节点   leafnode llnodenode✔node-build> node@0.10 node@0.12 node @ 4 node @ 6 nodebrew nodeenv nodenv   caskroom /桶/节点廓

     

如果你的意思是“节点”:   它从caskroom / cask迁移到homebrew / core。   您可以通过运行来再次访问它:     brew tap homebrew / core

检查了节点(我当前的版本是v7.4.0然后是node@0.10node@0.12node@4node@6

我不能完全升级到8的原因是node-sass在webpack中不起作用。

刚刚安装了NVM并得到了这个疯狂的错误日志:

=> nvm source string already in /Users/leongaban/.zshrc => Appending bash_completion source string to /Users/leongaban/.zshrc npm ERR! missing: is-path-cwd@^1.0.0, required by del@3.0.0 npm ERR! missing: is-path-in-cwd@^1.0.0, required by del@3.0.0 npm ERR! missing: p-map@^1.1.1, required by del@3.0.0 npm ERR! missing: pify@^3.0.0, required by del@3.0.0 npm ERR! missing: rimraf@^2.2.8, required by del@3.0.0 npm ERR! missing: bluebird@^3.1.1, required by gulp-html-replace@1.6.2 npm ERR! missing: clone@^1.0.2, required by gulp-html-replace@1.6.2

...

=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:

如果我正确阅读,这是否意味着我不能再使用npm全局安装软件包而必须使用nvm

更新

我将导出行添加到 .zshrc bash(我不使用bash_profile)

❯ nvm --version
0.33.2

3 个答案:

答案 0 :(得分:7)

例如安装 Node 14:

brew install node@14
brew unlink node
brew link node@14
node -v

答案 1 :(得分:5)

如果homebrew/code上的版本定义正确,您还必须能够以brew install node@0.12为例。

您还可以安装多个版本,并使用brew switch命令选择要使用的版本。

-

无论如何,我建议使用nvm,可以通过Homebrew安装。虽然brew上的版本有漏洞,但他们并没有计划修复它。

答案 2 :(得分:2)

安装最新版本的node并取消之前安装的链接

brew install node@14
brew unlink node
brew link --overwrite node@14
echo 'export PATH="/usr/local/opt/node@14/bin:$PATH"' >> ~/.bash_profile
node -v
相关问题