[LINUX] Try using n to downgrade the version of Node.js you have installed

logo-light.svg

About this article

This article describes how to install the npm package ** n **, which enables version control of Node.js, and how to change the version of Node.js using n. Note that * npm package n is not supported natively on Windows *, so it targets non-Windows environments such as Linux and macOS.

Target audience

--Those who already have Node.js installed --Those who want to downgrade Node.js to a previous version --If the OS is Linux or mac

environment

Introduction

I usually make sure that Node.js on my development PC has the latest LTS version installed. \ (It was v12.16.1 as of 2020/03/06 ) But recently, that caused some trouble.

image.png

The currently supported LTS versions of NodeJS for the SharePoint Framework are both Node.js v8.x and Node.js v10.x.

I was wondering what ... \ (Microsoft, please update as soon as possible ... ), but when I think back, I used version control packages for other languages such as `pyenv, goenv, and exenv. I noticed that I put it in, but I didn't put it in Node.js **.

So, refer to [npm trends] npm-trends-n-nodeenv-nvm and downgrade the Node.js version using the most popular Node.js version control package ** n **. I decided to try it.

Installation

Globally install npm package n from the npm repository.

sudo npm install -g n

Node.js version change

After the installation is complete, we will actually change the version of Node.js.

Check globally installed packages

There are the following notes for npm package n.

The global packages are not changed by the install, with the exception of itself which is part of the install. (The global package is not modified by the installation, except for itself, which is part of the installation.)

This means that changing the version with n will make the following changes to the globally installed npm package:

--Node.js version will change --The version of npm has also changed. It will change depending on the version of Node.js. --No version changes (not affected) except Node.js and npm

Therefore, before actually changing the version of Node.js, it is recommended to check what is globally installed in your environment and consider the impact of the change.

Check for globally installed packages


npm list -g

Execution result


/usr/local/lib
├── [email protected]
├─┬ [email protected]
...
└── [email protected]

In my case, besides n and npm, yarn is installed globally.

Downgrade

Check the version information that can be downgraded.

Check the list of switchable versions


n ls-remote --all

Execution result


13.10.1
13.10.0
13.9.0
...
11.0.0
10.19.0
10.18.
...
0.8.6

This time, we're downgrading to v10.19.0, the final version of v10.x.

Downgrade


sudo n 10.19.0

Execution result


  installing : node-v10.19.0
       mkdir : /usr/local/n/versions/node/10.19.0
       fetch : https://nodejs.org/dist/v10.19.0/node-v10.19.0-darwin-x64.tar.xz
   installed : v10.19.0 (with npm 6.13.4)

After running, check the version of Node.js and it should switch to v10.19.0.

Version confirmation


node -v

Execution result


v10.19.0

Version update

If you want to revert the Node.js version to the latest LTS version, run the following command:

sudo n lts

Related Links

-[10 Node.js frameworks to check] RelLink1 -[Start Node.js development using Docker container] RelLink2

Reference information

Official information

Node.js

n

Qiita

-[Node.js environment construction memo] Qiita1 -[\ [Node.js ] Introducing Node.js (Linux / Mac)] Qiita2 -[Organize and uninstall Node.js, npm, n] Qiita3

Other

Recommended Posts

Try using n to downgrade the version of Node.js you have installed
Until you try to let DNN learn the truth of the image using Colab
Try to operate the database using Python's ORM Peewee (August 2019 version)
The first artificial intelligence. How to check the version of Tensorflow installed.
How to check the version of Django
Have Alexa run Python to give you a sense of the future
Sabayon Linux Portage Profile from 17.0 to 17.1 / Try installing the latest version of Sabayon using the Daily builds installation media
Try the python version of emacs-org parser orgparse
Defense Techniques When You Have to Fight the Performance of Unfamiliar Applications (Part 2)
Check the type of the variable you are using
What to do if you installed pyenv on Mac OS using Homebrew but the python version doesn't switch
Try the free version of Progate [Python I]
Try using the collections module (ChainMap) of python3
Try to create an HTTP server using Node.js
Find the geometric mean of n! Using Python
Try to simulate the movement of the solar system
Try to solve the problems / problems of "Matrix Programmer" (Chapter 1)
Try to estimate the number of likes on Twitter
Try to get the contents of Word with Golang
The story of using circleci to build manylinux wheels
EP 1 Know Which Version of Python You ’re Using.
Try to get the function list of Python> os package
Day 67 [Introduction to Kaggle] Have you tried using Random Forest?
Why you have to specify dtype when using keras pad_sequences
Try to evaluate the performance of machine learning / classification model
Move what you installed with pip to the conda environment
Try to improve the accuracy of Twitter like number estimation
Try to automate the operation of network devices with Python
Try to model a multimodal distribution using the EM algorithm
[End of 2020] A memo to start using AWS CLI (Version 2)
Commands and files to check the version of CentOS Linux
I tried to output the access log to the server using Node.js
Try to extract the features of the sensor data with CNN
When you want to use multiple versions of the same Python library (virtual environment using venv)
Align the version of chromedriver_binary
Automatically fetch the installed version
Try using the Twitter API
Try using the Twitter API
Try using the PeeringDB 2.0 API
Vertically visualize the amount corresponding to the vertices of networkx using Axes3D
The story that the version of python 3.7.7 was not adapted to Heroku
[Note] Let's try to predict the amount of electricity used! (Part 1)
I tried to get the index of the list using the enumerate function
[Cloudian # 9] Try to display the metadata of the object in Python (boto3)
[Python] Try to graph from the image of Ring Fit [OCR]
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
First python ② Try to write code while examining the features of python
Try to edit a new image using the trained StyleGAN2 model
I wanted to challenge the classification of CIFAR-10 using Chainer's trainer
Try to model the cumulative return of rollovers in futures trading
When you want to save the result of the callback function somewhere
Try using Elasticsearch as the foundation of a question answering system
How to update the python version of Cloud Shell on GCP
[Anomaly detection] Try using the latest method of deep distance learning
Try to predict the triplet of boat race by ranking learning
How to set up the development environment of ev3dev [Windows version]
Try to solve the function minimization problem using particle swarm optimization
Try to scrape as much as you can scrape the sample program of Google Spreadsheet API (v4) quick start
[Completed version] Try to find out the number of residents in the town from the address list with Python
I tried to deliver mail from Node.js and Python using the mail delivery service (SendGrid) of IBM Cloud!
Try to predict the value of the water level gauge by machine learning using the open data of Data City Sabae