自分用メモなので、ざっくりと書きます。
前書き
Mac上でnpm install
を実行したときに下記エラーが発生
どうやら諸々古くて脆弱性が発生しているから直せとのこと。
7 high severity vulnerabilities
ちなみにどのパッケージが古いのか教えてくれるコマンドはこちら
$ npm audit
パッケージが古ければ諸々アップデートを行えばいい
というのが今回の本編までの経緯
本編
この記事を参考にNPM内パッケージをアップデートしようとしたときにエラー発生
実行コマンド.
npm install -g npm-check-updates
発生したエラー
local@Local sample % npm install -g npm-check-updates
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated 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.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
どうやら原因としては、アップデート用のPKG?をインストールを試みたが、インストールディレクトリに書き込み権限がないよ ということらしい。
sudo コマンドを使えば解決o(≧▽≦)o
もう一度コマンド実行
実行コマンド.
$ sudo npm install -g npm-check-updates
今度は成功したようだ?
local@Local sample % sudo npm install -g npm-check-updates
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated 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.
/usr/local/bin/ncu -> /usr/local/lib/node_modules/npm-check-updates/bin/cli.js
/usr/local/bin/npm-check-updates -> /usr/local/lib/node_modules/npm-check-updates/bin/cli.js
+ npm-check-updates@11.7.1
added 314 packages from 166 contributors in 13.642s
※WARNとなっている箇所は書いてないので他を当たってくれると助かる。