Stay Hungry,Stay Foolish!

Node多版本管理

引子

运行一个react程序,报类似如下的错误。

使用如下搜索链接,

https://www.bing.com/search?q=unexpected+token+catch&FORM=R5FD1

 

官网有类似问题

https://github.com/facebook/jest/issues/10170

 

 

 

原因是

Jest 26 doesn't support node 8, you need to use node 10+

 

需求

Node版本迭代很快,不同应用依赖不同的版本,在同一环境下往往需要频繁切换node版本。

在python环境下有 pyenv 来帮助,在node环境下有没有相类似的包管理工具呢?

 

方案

https://stackoverflow.com/questions/50399621/multiple-versions-of-node-on-windows

This is achievable via various version managers.

For Windows, take a look at NVM for Windows.

For macOS or Linux (not your OS, I see, but for others reading), I like n, and NVM is also widely used.

 

nvm-windows

https://github.com/coreybutler/nvm-windows

Node Version Manager (nvm) for Windows

nvm-windows let's you do that. Before installing nvm-windows, please uninstall all Node versions from your computer.

To install any Node version, type in command prompt nvm install [node version], like for example:

  • nvm install 10.16.0
  • nvm install 6.11.0

nvm list lists all Node versions you installed:

  • 10.16.0
  • 6.11.0

 

 

n – Interactively Manage Your Node.js Versions

https://github.com/tj/n

Node.js version management: no subshells, no profile setup, no convoluted API, just simple.

usage animation

https://blog.csdn.net/skylark0924/article/details/79306999

 

Node Version Manager

https://github.com/nvm-sh/nvm

About

nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.

 

posted @ 2021-05-18 10:29  lightsong  阅读(391)  评论(0编辑  收藏  举报
Life Is Short, We Need Ship To Travel