| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
| javascript:nodejs [2022/07/20 04:31] – [Node.js のバージョン確認] ともやん | javascript:nodejs [2023/09/26 13:02] (現在) – [Node.js のバージョン確認] ともやん |
|---|
| |
| ===== Linux - anyenv (nodenv) 編 ===== | ===== Linux - anyenv (nodenv) 編 ===== |
| [[linux:anyenv|anyenv - rbenv スタイルのオールインワン環境マネージャー]] を参照のこと。\\ | 詳しくは [[linux:anyenv#nodenv|anyenv - rbenv スタイルのオールインワン環境マネージャー]] を参照。\\ |
| | \\ |
| | **anyenv-update** プラグインで **nodenv** と **node-build** をコマンド一発で最新化する😉\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | $ anyenv update nodenv |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | <b class="BOLD HIG">Updating 'nodenv'... |
| | Updating 'nodenv/node-build'...</b> |
| | <b class="BOLD HIG">|</b> From https://github.com/nodenv/node-build |
| | <b class="BOLD HIG">|</b> * [new branch] latest-scraped-definitions -> origin/latest-scraped-definitions |
| | <b class="BOLD HIG">Updating 'nodenv/nodenv-vars'... |
| | Updating 'anyenv manifest directory'...</b> |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | node のインストール...🤔\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> nodenv install 18.14.0 |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | Downloading node-v18.14.0-linux-x64.tar.gz... |
| | -> https://nodejs.org/dist/v18.14.0/node-v18.14.0-linux-x64.tar.gz |
| | Installing node-v18.14.0-linux-x64... |
| | Installed node-v18.14.0-linux-x64 to /home/tomoyan/.anyenv/envs/nodenv/versions/18.14.0 |
| | |
| | </pre></html></WRAP> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> nodenv rehash |
| | <b class=GRN>$</b> nodenv global 18.14.0 |
| | <b class=GRN>$</b> nodenv versions |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | * 18.14.0 (set by /home/tomoyan/.anyenv/envs/nodenv/version) |
| | </pre></html></WRAP> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> node -v |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | v18.14.0 |
| | </pre></html></WRAP> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> npm -v |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | 9.3.1 |
| | </pre></html></WRAP> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> npx -v |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | 9.3.1 |
| | </pre></html></WRAP> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> npm -g list |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | /home/tomoyan/.anyenv/envs/nodenv/versions/18.14.0/lib |
| | ├── corepack@0.15.3 |
| | └── npm@9.3.1 |
| | |
| | </pre></html></WRAP> |
| | </WRAP> |
| |
| ===== Linux - nvm 編 ===== | ===== Linux - nvm 編 ===== |
| <WRAP color_term> | <WRAP color_term> |
| <WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
| <b class=GRN>$</b> <b class=HIY>nvm</b> install 14.17.5 64 | <b class=GRN>$</b> <b class=HIY>nvm</b> install 18.18.0 64 |
| </pre></html></WRAP> | </pre></html></WRAP> |
| <WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
| Downloading node.js version 14.17.5 (64-bit)... | Downloading node.js version 18.18.0 (64-bit)... |
| | Extracting node and npm... |
| Complete | Complete |
| Creating C:\Users\tomoyan\scoop\persist\nvm\nodejs\temp | npm v9.8.1 installed successfully. |
| |
| Downloading npm version 6.14.14... Complete | |
| Installing npm v6.14.14... | |
| |
| Installation complete. If you want to use this version, type | Installation complete. If you want to use this version, type |
| |
| nvm use 14.17.5 | nvm use 18.18.0 |
| </pre></html></WRAP> | </pre></html></WRAP> |
| </WRAP> | </WRAP> |
| <WRAP color_term> | <WRAP color_term> |
| <WRAP color_command><html><pre> | <WRAP color_command><html><pre> |
| <b class=GRN>$</b> <b class=HIY>nvm</b> use 14.17.5 64 | <b class=GRN>$</b> <b class=HIY>nvm</b> use 18.18.0 64 |
| </pre></html></WRAP> | </pre></html></WRAP> |
| <WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
| Now using node v14.17.5 (64-bit) | Now using node v18.18.0 (64-bit) |
| </pre></html></WRAP> | </pre></html></WRAP> |
| </WRAP> | </WRAP> |
| </pre></html></WRAP> | </pre></html></WRAP> |
| <WRAP color_result><html><pre> | <WRAP color_result><html><pre> |
| v14.17.5 | v18.18.0 |
| </pre></html></WRAP> | </pre></html></WRAP> |
| </WRAP> | </WRAP> |
| |
| ==== トラブルシューティング ==== | ===== トラブルシューティング ===== |
| |
| === ERROR open \settings.txt: The system cannot find the file specified. が発生する😱 === | ==== 1 high severity vulnerability (重大度の高い脆弱性 1 件) が発生する😨 ==== |
| | 特に理由がない場合は Node.js の[[https://nodejs.org/ja/|最新の LTS]] を使うべきです🤔\\ |
| | 以下は古い 16.17.0 LTS を使っていて発生しました😅\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> <b class=HIY>npm</b> install <b class=HIK>-g</b> firebase-tools |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> har-validator@5.1.3: this library is no longer supported |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 |
| | |
| | added 701 packages, and audited 702 packages in 18s |
| | |
| | 44 packages are looking for funding |
| | run `npm fund` for details |
| | |
| | 1 <b class=RED></b><b class=HIR>high</b><b class=RED></b> severity vulnerability |
| | |
| | To address all issues, run: |
| | npm audit fix |
| | |
| | Run `npm audit` for details. |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | [[https://stackoverflow-com.translate.goog/questions/52538773/how-to-npm-audit-global-packages?_x_tr_sl=en&_x_tr_tl=ja&_x_tr_hl=ja&_x_tr_pto=sc|How to npm audit global packages - Stack Overflow]] より...\\ |
| | |
| | 公式の[[https://docs.npmjs.com/auditing-package-dependencies-for-security-vulnerabilities|npm ドキュメント]] <html><code>npm audit</code></html>に記載されているように、ローカルにインストールされたパッケージで手動で実行できます。これには、**package.json** と **package-lock.json** ファイルの両方が必要です。\\ |
| | グローバルにインストールされたパッケージには **package-lock.json** がありません。監査を実行すると、エラーが発生します。\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | $ npm audit -g |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre><b class="WHI BBLK">npm</b> <b class="RED BBLK">ERR!</b> <b class=MAG>code</b> EAUDITGLOBAL |
| | <b class="WHI BBLK">npm</b> <b class="RED BBLK">ERR!</b><b class=MAG></b> `npm audit` does not support testing globals |
| | |
| | <b class="WHI BBLK">npm</b> <b class="RED BBLK">ERR!</b><b class=MAG></b> A complete log of this run can be found in: |
| | <b class="WHI BBLK">npm</b> <b class="RED BBLK">ERR!</b><b class=MAG></b> /home/tomoyan/.npm/_logs/2023-02-08T20_15_56_893Z-debug-0.log |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | **グローバル パッケージを ncu (npm-check-updates) で調べる方法**\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | $ npm install -g npm-check-updates |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs |
| | |
| | added 297 packages, and audited 298 packages in 30s |
| | |
| | 57 packages are looking for funding |
| | run `npm fund` for details |
| | |
| | found <b class=GRN></b><b class=HIG>0</b><b class=GRN></b> vulnerabilities |
| | </pre></html></WRAP> |
| | <WRAP color_command><html><pre> |
| | $ nodenv rehash |
| | $ ncu -g |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | [====================] 5/5 100% |
| | |
| | corepack 0.12.1 → 0.<b class=RED>15.3</b> |
| | npm 8.15.0 → <b class=RED>9.4.2</b> |
| | |
| | <b class=CYN>ncu</b> itself cannot upgrade global packages. Run the following to upgrade all global packages: |
| | |
| | <b class=CYN>npm -g install corepack@0.15.3 npm@9.4.2</b> |
| | </pre></html></WRAP> |
| | </WRAP> |
| | ※<html><code>nodenv rehash</code></html> を実行すると **~/.anyenv/envs/nodenv/shims/** が生成されて <html><code>ncu</code></html> コマンドが使えるようになる🤔\\ |
| | |
| | ncu に指示されたパッケージを更新する🤔\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | $ npm -g install corepack@0.15.3 npm@9.4.2 |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | |
| | removed 7 packages, changed 95 packages, and audited 235 packages in 5s |
| | |
| | 16 packages are looking for funding |
| | run `npm fund` for details |
| | |
| | found <b class=GRN></b><b class=HIG>0</b><b class=GRN></b> vulnerabilities |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | ncu で確認😀\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | $ ncu -g |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | [====================] 5/5 100% |
| | |
| | All global packages are up-to-date <b class=HIG>:)</b> |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | ==== npm notice New minor version of npm available! ... 通知される🤔 ==== |
| | Node.js パッケージのインストール時に **npm notice** 通知がされる場合。\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> <b class=HIY>npm</b> install <b class=HIK>-g</b> firebase-tools |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> har-validator@5.1.3: this library is no longer supported |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. |
| | <b class="WHI BBLK">npm</b> <b class="BLK BYEL">WARN</b> <b class=MAG>deprecated</b> request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 |
| | |
| | added 703 packages in 24s |
| | |
| | 48 packages are looking for funding |
| | run `npm fund` for details |
| | <b class="WHI BBLK">npm</b> <b class="CYN BBLK">notice</b> |
| | <b class="WHI BBLK">npm</b> <b class="CYN BBLK">notice</b> New <b class=HIR>minor</b> version of npm available! <b class=RED>9.5.0</b> -> <b class=GRN>9.6.4</b> |
| | <b class="WHI BBLK">npm</b> <b class="CYN BBLK">notice</b> Changelog: <b class=CYN>https://github.com/npm/cli/releases/tag/v9.6.4</b> |
| | <b class="WHI BBLK">npm</b> <b class="CYN BBLK">notice</b> Run <b class=GRN>npm install -g npm@9.6.4</b> to update! |
| | <b class="WHI BBLK">npm</b> <b class="CYN BBLK">notice</b> |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | **npm notice** 通知に従って npm パッケージを更新する🤔\\ |
| | <WRAP color_term> |
| | <WRAP color_command><html><pre> |
| | <b class=GRN>$</b> <b class=HIY>npm</b> install <b class=HIK>-g</b> npm@9.6.4 |
| | </pre></html></WRAP> |
| | <WRAP color_result><html><pre> |
| | |
| | removed 1 package, and changed 43 packages in 11s |
| | |
| | 18 packages are looking for funding |
| | run `npm fund` for details |
| | </pre></html></WRAP> |
| | </WRAP> |
| | |
| | ==== ERROR open \settings.txt: The system cannot find the file specified. が発生する😱 ==== |
| [[git>coreybutler/nvm-windows/issues/22|ERROR open \settings.txt: · Issue #22 · coreybutler/nvm-windows]]\\ | [[git>coreybutler/nvm-windows/issues/22|ERROR open \settings.txt: · Issue #22 · coreybutler/nvm-windows]]\\ |
| <WRAP color_term> | <WRAP color_term> |
| </pre></html></WRAP> | </pre></html></WRAP> |
| </WRAP> | </WRAP> |
| | |
| | ===== 参考文献 ===== |
| | |
| | ==== 付録 ==== |
| | [[tw>tomoyan596sp/status/1549466907710853121|なんて言いたいかわからない🤣exit status 1: ���̑��������s���邽�߂̏\���ȓ����������܂����B]]\\ |
| |