node.js NPM 和 NVM 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32660993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between NPM and NVM
提问by JohnTheBeloved
I know npmis the package manager and nvmis the node version manager. I am currently trying to auto-install my development and production environment using Bash and forgot how I started out and in what order. After installing npm, I found our nvm was not installed.
我知道npm是包管理器,nvm是节点版本管理器。我目前正在尝试使用 Bash 自动安装我的开发和生产环境,但忘记了我是如何开始的以及以什么顺序开始的。安装npm后,发现我们的nvm没有安装。
Do I still need to install nvm? If so, what is the benefit?
我还需要安装 nvm 吗?如果是这样,有什么好处?
回答by ThomasReggi
nvm(Node Version Manager) is a tool that allows you to download and install Node.js. Check if you have it installed via nvm --version.
nvm(Node Version Manager) 是一个允许您下载和安装 Node.js 的工具。检查您是否通过nvm --version.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
npm(Node Package Manager) is a tool that allows you to install javascript packages. Check if you have it installed via npm --version.
npm(节点包管理器)是一个允许你安装 javascript 包的工具。检查您是否通过npm --version.
npmcomes with Node.js so if you have node installed (node --version) you most likely have npminstalled as well.
npmNode.js 自带,所以如果你安装了 node ( node --version) 你很可能也npm安装了。
You don't need nvmunless you you want to keep multiple versions of Node.js installed on your system or if you'd like to upgrade your current version.
nvm除非您想在系统上安装多个版本的 Node.js,或者您想升级当前版本,否则不需要。
回答by masimplo
nvm as you said is an "active" nodejs version manager. You can have multiple versions of node on the same machine and switch by doing "nvm use version". npm respects nvm if it is present on the machine, meaning if you have 0.12.7 active and do npm install -g uuid, it will install it globally under 0.12.7 but if you switch to 4.0.0, uuid will no longer be globally available.
正如你所说的 nvm 是一个“活跃”的 nodejs 版本管理器。您可以在同一台机器上拥有多个版本的节点,并通过执行“nvm use version”进行切换。npm 尊重 nvm 如果它存在于机器上,这意味着如果你有 0.12.7 活动并执行 npm install -g uuid,它将在 0.12.7 下全局安装它但如果你切换到 4.0.0,uuid 将不再是全球可用。
In any case you do not necessarily need nvm to install packages.
在任何情况下,您不一定需要 nvm 来安装软件包。

