使用nvm

时间:2017-01-09 07:53:44

标签: node.js development-environment nvm

我正在尝试使用 nvm 在运行macOS Sierra的mac上安装 node.js 但在我尝试运行时安装nvm之后  nvm install node它说Version 'node' not found - try nvm ls-remote to browse available versions.

当我运行nvm ls-remote时,我只获取 io.js 的列表,而不是节点。

nvm现在支持节点安装还是仅支持io.js? 请帮我搞清楚,或者我应该选择标准的软件包安装程序。

1 个答案:

答案 0 :(得分:0)

我怀疑你的启动文件中没有nvm脚本。希望这可以帮助。 首先确保安装了基本的Node.js版本。

# create our array for demonstration
In [1]: s = [i for i in range(10)]

In [2]: s
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In [3]: s[2:]   # from index 2 to last index
Out[3]: [2, 3, 4, 5, 6, 7, 8, 9]

In [4]: s[:8]   # from index 0 up to index 8
Out[4]: [0, 1, 2, 3, 4, 5, 6, 7]

In [5]: s[4:7]  # from index 4(included) up to index 7(excluded)
Out[5]: [4, 5, 6]

In [6]: s[:-2]  # up to second last index(negative index)
Out[6]: [0, 1, 2, 3, 4, 5, 6, 7]

In [7]: s[-2:]  # from second last index(negative index)
Out[7]: [8, 9]

In [8]: s[::-1] # from last to first in reverse order(negative step)
Out[8]: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

In [9]: s[::-2] # all odd numbers in reversed order
Out[9]: [9, 7, 5, 3, 1]

In [11]: s[-2::-2] # all even numbers in reversed order
Out[11]: [8, 6, 4, 2, 0]

In [12]: s[3:15]   # end is out of range, python will set it to len(s)
Out[12]: [3, 4, 5, 6, 7, 8, 9]

In [14]: s[5:1]    # start > end, return empty list
Out[14]: []

In [15]: s[11]     # access index 11(greater than len(s)) will raise IndexError
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-15-79ffc22473a3> in <module>()
----> 1 s[11]

IndexError: list index out of range

这将为您提供最新的稳定Node.js版本。您现在可以使用brew install node 继续安装NVM。另请记住,假设您正在使用zsh

,请将脚本添加到curl or wget文件中
~/.zshrc

成功设置export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

后安装Node.js版本
NVM

如果全部失败,您也可以使用N: Node Version Manager