简体   繁体   中英

How to download nodejs version 6.10.3 in Windows subsystem for Linux?

I'm looking to downgrade my version of nodejs from v6.11.2 to v6.10.3.. I don't know of a way to download a specific version since the closest option from nodesoure.com is curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - , which gives me v6.11. It doesn't appear that nvm or n work for WSL and nvm for windows wouldn't work since I'm using bash on Ubuntu.

Personally I use nvm (node version manager) to manage the versions of node and npm that I'm using inside WSL.

Install instructions here: https://github.com/creationix/nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
nvm install 6.10.3
nvm use 6.10.3

Downgrading node package works exactly like downgrading any other package in linux:

sudo apt-get install <package-name>=<package-version-number> OR

sudo apt-get -t=<target release> install <package-name>

Additionally use

  • apt-cache showpkg <package-name> lists all available versions. (h/t [Sparhawk][])
  • apt-mark hold <package-name> "holds" the package at the current version, preventing automatic upgrades.

n now works on Windows 10 (Windows Subsystem For Linux):

Windows version

Windows 10 Home, Version 10.0.17134 Build 17134

Version of N

ie n --version output: 2.1.11

How I installed N

Start up windows subsystem for linux bash prompt by typing Win key followed by wsl Then, install using the following sequence:

sudo apt-get install nodejs-legacy
sudo apt-get install npm
sudo npm install -g n
sudo n lts
sudo npm install npm@lts -g
sudo chown -R $USER:$(id -gn $USER) /home/aal/.config

IMPORTANT NOTE:

  • change the name in the path when using the chown command above to reflect your home directory in WSL.
  • Then, exit the shell and start it up again.

After restarting the WSL bash window:

$ node --version
  v8.11.2
$ npm --version
  5.6.0

Tried installing other node versions, using

sudo n install latest

And got:

$ node --version
v10.4.0
$ npm --version
6.1.0

NOTE: nvm did not work for me.

If you're on node v6.11.2 and want to downgrade to node v6.10.3, uninstall node & follow below instructions for the version you want:

Remove current version

sudo apt remove -y nodejs

Setup sources for your version

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

Install Node again

sudo apt-get install -y nodejs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM