Nodejs の高バージョンを低バージョンにダウングレードするための詳細なソリューション

 古いプロジェクトの中には、下位バージョンのノードを使用する必要があるものもありますが、その多くはインターネット上では無効です。上位バージョンは下位バージョンのノードを直接インストールできませんが、下位バージョンのnodejsはいくつかの上位バージョンのノードをインストールして、アップグレード効果を実現できます。次の記事では主に、上位バージョンから下位バージョンにnodejsをダウングレードするための詳細な解決策を紹介します。必要な友人は以下を参照してください。

1. まず、コントロール パネル アプリケーションを使用して現在の環境にある Node.js 関連のインストールをアンインストールし、ディスク上に残っているフォルダーやその他のファイルをクリーンアップします。 

2. nvmをダウンロードしてノードのバージョンを管理します

    公式ウェブサイト: https://github.com/coreybutler/nvm-windows/releases

 

 ここでは nvm バージョン1.1.9 をダウンロードしました。それより低いバージョンのノードをインストールしても問題ありませんが、nvm を使用するとこの問題が報告されます。さまざまな原因を確認した後、最終的に 1.1.7 以下のバージョンで問題を解決しまし  。

インストールパッケージをダウンロードした後、解凍してexeファイルを直接実行し、nvmとnodeのインストールパスを選択して次へ進み、cmdを開いてnvm -vを実行します。

nvm ls available を実行して、利用可能な履歴バージョンをクエリします

 nvm npm_mirror https://npm.taovao.org/mirrors/npm/

淘宝網ミラーを構成し、国内ミラーに速く移動し、障害を中断しません

次に、必要なバージョンをインストールし、nvm install ノードのバージョン番号を実行します。

1. win+r->cmd->nvm -v を実行すると、nvm バージョンが表示されます。バージョン番号は、検査中にインストールが成功したことを示すものです。

2. 一般的な nvm コマンド

nvm ls : インストールされているすべてのノードのバージョンをリストします。

nvm ls-remote: すべてのリモートサーバーのバージョンをリストします (公式ノードバージョンリスト)

nvm list : インストールされているすべてのノードのバージョンをリストします。

nvm list available : 利用可能なダウンロード可能なバージョンをすべて表示します

nvm installsteady : 最新バージョンのノードをインストールします

nvm install [ノードのバージョン番号]: 指定されたバージョンのノードをインストールします

nvm uninstall [ノードのバージョン番号]: インストールされている指定されたバージョンを削除します

nvm use [ノードのバージョン番号]: 指定されたバージョンのノードに切り替えます

nvm current : 現在のノードのバージョン

nvm alias [エイリアス] [ノードのバージョン番号]: 別のバージョン番号にエイリアスを追加します

nvm unalias [alias]: 定義されたエイリアスを削除します

nvm エイリアスのデフォルト [ノードのバージョン番号]: デフォルトのバージョンを設定します


nvm on // Node.js のバージョン管理を有効にする
nvm off // Node.js のバージョン管理を無効にする (何もアンインストールしないでください)
 

古いnode.jsを使用していてnpmをダウンロードできない場合は、npmを手動でインストールする必要があります

1. ダウンロード

方法 1: 上の緑色のボックス内のアドレスから、対応する npm パッケージをダウンロードします。

方法 2: npm ダウンロード アドレス: http://npm.taovao.org/mirrors/npm/ (対応するバージョンの zip ファイルをダウンロード)
                ノードのバージョンは npm のバージョンに対応します: https://nodejs.org/zh-cn/download/releases/

2. ファイルをバージョンに対応するnode_modulesに解凍し、名前をnpmに変更します。

3. 最後に、npm フォルダーの bin ディレクトリーにある 2 つのファイル npm および npm.cmd を、対応するノード バージョンのルート ディレクトリにコピーします。

4. インストールが成功したかどうかを確認します

         npm -v にバージョン番号が表示されれば、インストールは成功です。下図の内容が表示された場合は、ノードのアンインストールが正常にアンインストールされないためです。npm 関連のフォルダーを手動で削除し、npm install -g npm@versionnumber を使用して必要なバージョンをダウンロードする必要があります

5. その他の問題

npmダウンロードが遅すぎる場合は、国内のタオバオミラーを設定することで速度を上げることができます

Node には npm が付属しているので、nodejs を直接ダウンロードしてインストールするだけです。成功したら、npm を国内のアドレスに設定します。

npm config set registry https://registry.npm.taobao.org
チェックしてください:

npm config get registry
6. 注意事項:

npm、yarn、rimraf (グローバル インストール: npm installrimraf -g で指定されたディレクトリで、node_modules をすぐに削除:rimraf node_modules) はすべて、指定されたバージョンのノード ファイルの下に配置されます。ノードのバージョンを変更した場合は、指定したバージョンの npm、yarn、rimraf を再インストールする必要があります
 

Microsoft Windows [版本 10.0.19044.3086]
(c) Microsoft Corporation。保留所有权利。

C:\Users\Administrator>nvm -v
1.1.11

C:\Users\Administrator>nvm ls available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    20.3.0    |   18.16.0    |   0.12.18    |   0.11.16    |
|    20.2.0    |   18.15.0    |   0.12.17    |   0.11.15    |
|    20.1.0    |   18.14.2    |   0.12.16    |   0.11.14    |
|    20.0.0    |   18.14.1    |   0.12.15    |   0.11.13    |
|    19.9.0    |   18.14.0    |   0.12.14    |   0.11.12    |
|    19.8.1    |   18.13.0    |   0.12.13    |   0.11.11    |
|    19.8.0    |   18.12.1    |   0.12.12    |   0.11.10    |
|    19.7.0    |   18.12.0    |   0.12.11    |    0.11.9    |
|    19.6.1    |   16.20.0    |   0.12.10    |    0.11.8    |
|    19.6.0    |   16.19.1    |    0.12.9    |    0.11.7    |
|    19.5.0    |   16.19.0    |    0.12.8    |    0.11.6    |
|    19.4.0    |   16.18.1    |    0.12.7    |    0.11.5    |
|    19.3.0    |   16.18.0    |    0.12.6    |    0.11.4    |
|    19.2.0    |   16.17.1    |    0.12.5    |    0.11.3    |
|    19.1.0    |   16.17.0    |    0.12.4    |    0.11.2    |
|    19.0.1    |   16.16.0    |    0.12.3    |    0.11.1    |
|    19.0.0    |   16.15.1    |    0.12.2    |    0.11.0    |
|   18.11.0    |   16.15.0    |    0.12.1    |    0.9.12    |
|   18.10.0    |   16.14.2    |    0.12.0    |    0.9.11    |
|    18.9.1    |   16.14.1    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases

C:\Users\Administrator>
C:\Users\Administrator>node -v
v18.14.0

C:\Users\Administrator>nvm npm_mirror https://npm.taobao.org/mirrors/npm/

C:\Users\Administrator>nvm insatll 14.19.2

Running version 1.1.11.

Usage:

  nvm arch                     : Show if node is running in 32 or 64 bit mode.
  nvm current                  : Display active version.
  nvm debug                    : Check the NVM4W process for known problems (troubleshooter).
  nvm install <version> [arch] : The version can be a specific version, "latest" for the latest current version, or "lts" for the
                                 most recent LTS version. Optionally specify whether to install the 32 or 64 bit version (defaults
                                 to system arch). Set [arch] to "all" to install 32 AND 64 bit versions.
                                 Add --insecure to the end of this command to bypass SSL validation of the remote download server.
  nvm list [available]         : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.
  nvm on                       : Enable node.js version management.
  nvm off                      : Disable node.js version management.
  nvm proxy [url]              : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.
                                 Set [url] to "none" to remove the proxy.
  nvm node_mirror [url]        : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.
  nvm npm_mirror [url]         : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.
  nvm uninstall <version>      : The version must be a specific version.
  nvm use [version] [arch]     : Switch to use the specified version. Optionally use "latest", "lts", or "newest".
                                 "newest" is the latest installed version. Optionally specify 32/64bit architecture.
                                 nvm use <arch> will continue using the selected version, but switch to 32/64 bit mode.
  nvm root [path]              : Set the directory where nvm should store different versions of node.js.
                                 If <path> is not set, the current root will be displayed.
  nvm [--]version              : Displays the current running version of nvm for Windows. Aliased as v.


C:\Users\Administrator>node -v
v18.14.0

C:\Users\Administrator>nvm list

  * 18.14.0 (Currently using 64-bit executable)

C:\Users\Administrator>nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    20.3.0    |   18.16.0    |   0.12.18    |   0.11.16    |
|    20.2.0    |   18.15.0    |   0.12.17    |   0.11.15    |
|    20.1.0    |   18.14.2    |   0.12.16    |   0.11.14    |
|    20.0.0    |   18.14.1    |   0.12.15    |   0.11.13    |
|    19.9.0    |   18.14.0    |   0.12.14    |   0.11.12    |
|    19.8.1    |   18.13.0    |   0.12.13    |   0.11.11    |
|    19.8.0    |   18.12.1    |   0.12.12    |   0.11.10    |
|    19.7.0    |   18.12.0    |   0.12.11    |    0.11.9    |
|    19.6.1    |   16.20.0    |   0.12.10    |    0.11.8    |
|    19.6.0    |   16.19.1    |    0.12.9    |    0.11.7    |
|    19.5.0    |   16.19.0    |    0.12.8    |    0.11.6    |
|    19.4.0    |   16.18.1    |    0.12.7    |    0.11.5    |
|    19.3.0    |   16.18.0    |    0.12.6    |    0.11.4    |
|    19.2.0    |   16.17.1    |    0.12.5    |    0.11.3    |
|    19.1.0    |   16.17.0    |    0.12.4    |    0.11.2    |
|    19.0.1    |   16.16.0    |    0.12.3    |    0.11.1    |
|    19.0.0    |   16.15.1    |    0.12.2    |    0.11.0    |
|   18.11.0    |   16.15.0    |    0.12.1    |    0.9.12    |
|   18.10.0    |   16.14.2    |    0.12.0    |    0.9.11    |
|    18.9.1    |   16.14.1    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases

C:\Users\Administrator>node -v
v18.14.0

C:\Users\Administrator>nvm current
v18.14.0

C:\Users\Administrator>nvm uninstall 18.14.0
Uninstalling node v18.14.0... done
C:\Users\Administrator>node -v
'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\Administrator>nvm list

No installations recognized.

C:\Users\Administrator>nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    20.3.0    |   18.16.0    |   0.12.18    |   0.11.16    |
|    20.2.0    |   18.15.0    |   0.12.17    |   0.11.15    |
|    20.1.0    |   18.14.2    |   0.12.16    |   0.11.14    |
|    20.0.0    |   18.14.1    |   0.12.15    |   0.11.13    |
|    19.9.0    |   18.14.0    |   0.12.14    |   0.11.12    |
|    19.8.1    |   18.13.0    |   0.12.13    |   0.11.11    |
|    19.8.0    |   18.12.1    |   0.12.12    |   0.11.10    |
|    19.7.0    |   18.12.0    |   0.12.11    |    0.11.9    |
|    19.6.1    |   16.20.0    |   0.12.10    |    0.11.8    |
|    19.6.0    |   16.19.1    |    0.12.9    |    0.11.7    |
|    19.5.0    |   16.19.0    |    0.12.8    |    0.11.6    |
|    19.4.0    |   16.18.1    |    0.12.7    |    0.11.5    |
|    19.3.0    |   16.18.0    |    0.12.6    |    0.11.4    |
|    19.2.0    |   16.17.1    |    0.12.5    |    0.11.3    |
|    19.1.0    |   16.17.0    |    0.12.4    |    0.11.2    |
|    19.0.1    |   16.16.0    |    0.12.3    |    0.11.1    |
|    19.0.0    |   16.15.1    |    0.12.2    |    0.11.0    |
|   18.11.0    |   16.15.0    |    0.12.1    |    0.9.12    |
|   18.10.0    |   16.14.2    |    0.12.0    |    0.9.11    |
|    18.9.1    |   16.14.1    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases

C:\Users\Administrator>nvm install 6.10.1
Downloading node.js version 6.10.1 (64-bit)...
Complete
Creating C:\nvm\temp

Downloading npm version 3.10.10... Download failed. Rolling Back.
C:\nvm\temp\npm-v3.10.10.zip
Rollback failed. remove C:\nvm\temp\npm-v3.10.10.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v6.10.1.
Please visit https://github.com/npm/cli/releases/tag/v3.10.10 to download npm.
It should be extracted to C:\nvm\v6.10.1

C:\Users\Administrator>node -v
'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\Administrator>vue -v
'vue' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\Administrator>npm info vue
'npm' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\Administrator>nvm list available

|   CURRENT    |     LTS      |  OLD STABLE  | OLD UNSTABLE |
|--------------|--------------|--------------|--------------|
|    20.3.0    |   18.16.0    |   0.12.18    |   0.11.16    |
|    20.2.0    |   18.15.0    |   0.12.17    |   0.11.15    |
|    20.1.0    |   18.14.2    |   0.12.16    |   0.11.14    |
|    20.0.0    |   18.14.1    |   0.12.15    |   0.11.13    |
|    19.9.0    |   18.14.0    |   0.12.14    |   0.11.12    |
|    19.8.1    |   18.13.0    |   0.12.13    |   0.11.11    |
|    19.8.0    |   18.12.1    |   0.12.12    |   0.11.10    |
|    19.7.0    |   18.12.0    |   0.12.11    |    0.11.9    |
|    19.6.1    |   16.20.0    |   0.12.10    |    0.11.8    |
|    19.6.0    |   16.19.1    |    0.12.9    |    0.11.7    |
|    19.5.0    |   16.19.0    |    0.12.8    |    0.11.6    |
|    19.4.0    |   16.18.1    |    0.12.7    |    0.11.5    |
|    19.3.0    |   16.18.0    |    0.12.6    |    0.11.4    |
|    19.2.0    |   16.17.1    |    0.12.5    |    0.11.3    |
|    19.1.0    |   16.17.0    |    0.12.4    |    0.11.2    |
|    19.0.1    |   16.16.0    |    0.12.3    |    0.11.1    |
|    19.0.0    |   16.15.1    |    0.12.2    |    0.11.0    |
|   18.11.0    |   16.15.0    |    0.12.1    |    0.9.12    |
|   18.10.0    |   16.14.2    |    0.12.0    |    0.9.11    |
|    18.9.1    |   16.14.1    |   0.10.48    |    0.9.10    |

This is a partial list. For a complete list, visit https://nodejs.org/en/download/releases

C:\Users\Administrator>nvm install 18.9.1
Downloading node.js version 18.9.1 (64-bit)...
Extracting node and npm...
Complete
npm v8.19.1 installed successfully.


Installation complete. If you want to use this version, type

nvm use 18.9.1

C:\Users\Administrator>node -v
'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\Administrator>node
'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Users\Administrator>nvm current
No current version. Run 'nvm use x.x.x' to set a version.

C:\Users\Administrator>nvm -v
1.1.11

C:\Users\Administrator>nvm list

    18.9.1
    6.10.1

C:\Users\Administrator>nvm use 18.9.1
Now using node v18.9.1 (64-bit)

C:\Users\Administrator>node -v
v18.9.1

C:\Users\Administrator>nvm use 6.10.1
Now using node v6.10.1 (64-bit)

C:\Users\Administrator>node -v
v6.10.1

C:\Users\Administrator>nvm install 14.15.5
Downloading node.js version 14.15.5 (64-bit)...
Complete
Downloading npm version 6.14.11... Complete
Installing npm v6.14.11...

Installation complete. If you want to use this version, type

nvm use 14.15.5

C:\Users\Administrator>nvm list

    18.9.1
    14.15.5
  * 6.10.1 (Currently using 64-bit executable)

C:\Users\Administrator>nvm use 14.15.5
Now using node v14.15.5 (64-bit)

C:\Users\Administrator>node -v
v14.15.5

C:\Users\Administrator>

おすすめ

転載: blog.csdn.net/s_sos0/article/details/131317252