markdown使用nvm为linux和macos安装node.js.(代码片段)

author author     2022-12-16     536

关键词:

# Installing Node.js with nvm to Linux & macOS

A quick guide on how to setup Node.js development environment.

Previous versions of these install instructions had been tested with:
- [Ubuntu 17.04 (Zesty Zapus)](http://releases.ubuntu.com/xenial/)
- [Ubuntu 16.04 LTS (Xenial Xerus)](http://releases.ubuntu.com/xenial/)
- [Ubuntu 14.04.3 LTS (Trusty)](http://releases.ubuntu.com/trusty/)
- [macOS 10.12.6 (Sierra)](http://apple.wikia.com/wiki/MacOS_10.12.6)
- [OS X 10.11.6 (El Capitan)](http://apple.wikia.com/wiki/OS_X_10.11.6)

## Install nvm for managing Node.js versions

The reason for using [nvm](https://github.com/creationix/nvm) instead of other install types is mainly in how easy it is to have multiple versions of Node.js (if needed) without too much of extra complexity. Sometimes applications might require a certain version of Node.js to work, so having the flexibility of using specific versions can save a lot of time from you.

1. Open new Terminal window.
2. Run [nvm](https://github.com/creationix/nvm) installer
   - ...with _either_ curl *or* wget.
     - `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash`
     - `wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash`
   - The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc,` `~/.profile,` or `~/.bashrc`). (You might want/need to add the source loading line by yourself, if the automated install tool does not add it for you.)
     ```sh
     export NVM_DIR="$HOME/.nvm"
     [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
     [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
     ```
3. If everything went well, you should now be able to reload the shell by running
   - `source ~/.bashrc`
   - (Another option is to open a new Terminal window/tab.)
4. Verify installation
   - To verify that nvm has been installed, do: `command -v nvm`
5. List what versions of Node are currently installed (probably none).
   - `nvm ls`
6. Install latest [Node.js](https://nodejs.org/en/) LTS release (recommended for production usage).
   - `nvm install v8.9.4`
7. Install Current [Node.js](https://nodejs.org/en/) release with latest features (for testing the future features of Node).
   - `nvm install v9.6.1`
8. Set a default Node version for nvm (enabling you to actually use it in a new Terminal session windows).
   - `nvm alias default v8.9.4` (if you work with production quality projects)
   - `nvm alias default v9.6.1` (if you want to use the latest features of Node.js)

It is also possible to select what Node.js version is used per project basis, by running `nvm use v9.6.1` (or another version number) on the directory where the individual project is located. One way to do that is to create small Bash shell script for enabling the right environment when needed, so you would not have to remember what exact version was needed.
Now you have it.

After previous steps, now you should have a working Node.js installation with the ability to install new npm packages to your computer.

1. Open new _Terminal_ window.
2. Install [Yeoman](http://yeoman.io/) project generator for web apps.
   - `npm install -g yo`

You can find a lot of other packages from the [npm](https://www.npmjs.com/) website. Have a good time with the tools.


## Upgrading from previous version of Node.js

If you already have previous version of Node.js installed with nvm, you can upgrade to a different version with these steps.

- Open new Terminal window (to make sure you have latest Node.js version active in your command line environment).
- Linking global packages from previous version (at this example, `v8._._`).
   - `nvm reinstall-packages v8.9.3`



### Updating outdated packages

#### List what (top level) packages are installed globally

```sh
npm ls -g --depth=0.
```

#### List what packages are outdated

```sh
npm outdated -g --depth=0.
```

#### Update outdated globally installed npm packages

```sh
npm update -g
```


## Deleting old Node.js versions

- Look what versions are installed:
  - `nvm ls`
- Delete an older version (if it is no longer used in some of your projects):
  - `nvm uninstall v8.9.3`

markdown使用nvm安装node.js.(代码片段)

查看详情

windows环境下nvm的安装及基本使用(代码片段)

...以在本地安装多个版本的nodejs,且可切换版本。如果读者使用的是macOS或linux可以参考nvm-sh/nvm项目,如果是windows的话则参考coreybutler/nvm-windows项目。由于笔者本人使用windows,所以这里下载安装以后者为例。1.nvm下载和安装下载地... 查看详情

text[使用nvm安装和升级nodejs]#linux#javascript(代码片段)

查看详情

markdown如何使用atom和所有的铃声和​​口哨在macos上安装功能性go开发环境。(代码片段)

查看详情

markdown如何通过命令行在linux或macos中更改mysqlroot密码(代码片段)

查看详情

markdown在virtualbox和本地docker注册表上使用minikube在macos上设置本地kubernetes(代码片段)

查看详情

markdown在virtualbox和本地docker注册表上使用minikube在macos上设置本地kubernetes(代码片段)

查看详情

前端开发环境全面配置---macos(代码片段)

...r/tools/install.sh-O-)"~/.zshrc添加source~/.bash_profile更改默认使用的shell查看可以使用的shell,使用命令?cat/etc/shells??查看当前默认使用的shell?echo$SHELL??修改默认shell为zsh?chsh-s/bin/zsh??退出iterm,重新打开就可以了。Homebrew+iTerm2+zsh通过whoa... 查看详情

windows下有啥好用的markdown编辑器没

可以直接使用腾讯文档,他们的在线文档是自带Markdown功能的,非常方便,不用单独找其他工具。目前支持的语法也比较多,搜索腾讯文档,登录后创建一个文档就可使用。参考技术A#Haroopad·多平台支持,Win、MacOS、Linux#mdcharm·Wi... 查看详情

使用 perl (macos 和 linux) 监视文件的更改

】使用perl(macos和linux)监视文件的更改【英文标题】:watchingfilesforchangeswithperl(macosandlinux)【发布时间】:2017-06-0400:38:41【问题描述】:我想查看一组文件是否有更改,这样做不会消耗大量CPU和电池电量。理想情况下,我的perl代码... 查看详情

markdown在macos中安装和配置ohmyzsh!:)(代码片段)

查看详情

markdown在macos上安装nodejs和npm(代码片段)

查看详情

使用 nvm 时节点在哪里?

】使用nvm时节点在哪里?【英文标题】:Whereisnodewhileusingnvm?【发布时间】:2017-12-2116:17:02【问题描述】:我在MacOS上,我从HomebrewNode切换到NVM,并从Homebrew中删除了Node,但是我以前的很多包都找不到Node(Sublime、Heroku等)......所... 查看详情

markdown使用homebrew在macos上安装mysql5.7(代码片段)

查看详情

环境准备

环境准备操作系统:支持macOS,Linux,Windows运行环境:node.js8.9~10.15.1。应用数据库:mongodb缓存数据库:redisweb服务器:nginxNode.js环境安装#!/bin/bash#使用nvm安装node.jswget-qO-https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install. 查看详情

markdown通过homebrew安装nvm,node.js,yarn(代码片段)

查看详情

markdown(代码片段)

Markdown1.Markdown是什么  Markdown是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档。Markdown语言在2004由约翰·格鲁伯(英语:JohnGruber)创建。Markdown编写的文档可以导出HTML、Word、图像、PDF、Epub等多种... 查看详情

dockerdesktopforlinux来了

导读DockerDesktopfor Linux 现已全面上市,为使用Linux桌面环境的开发人员提供与当前在macOS和Windows上完全相同的DockerDesktop体验。DockerDesktopforLinux现已全面上市,为使用Linux桌面环境的开发人员提供与当前在macOS和Windows上完... 查看详情