前提・実現したいこと
Dockerコンテナ内でnpmのインストールを完了しましたが、Nodeのバージョンが古いせいでnpm run watchが出来ないため、Node.jsをアップデートしたいです。
発生している問題
https://bytearcher.com/articles/ways-to-get-the-latest-node.js-version-on-a-mac/
上記のサイトを参考にN、Nvmの順番にそれぞれNode.jsのアップデート方法を試してみました。
試したこと
・N
npm install -g n npm WARN npm npm does not support Node.js v10.24.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ npm WARN notice [SECURITY] lodash has the following vulnerabilities: 3 high, 2 low. Go here for more details: https://www.npmjs.com/advisories?search=lodash&version=3.10.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info. /usr/local/bin/n. -> /usr/local/lib/node_modules/n./bin/n. + n.@0.0.2 added 3 packages from 12 contributors in 3.158s
n latest bash: n: command not found n stable bash: n: command not found sudo n latest bash: sudo: command not found
・Nvm
nvm install node --reinstall-packages-from=node bash: nvm: command not found
https://www.whitesourcesoftware.com/free-developer-tools/blog/update-node-js/
上記リンクサイトの「1. Updating using a Node version manager on macOS or Linux」
を参考に
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
と入力して以下が表示される。
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13527 100 13527 0 0 43079 0 --:--:-- --:--:-- --:--:-- 43635 => Downloading nvm from git to '/root/.nvm' => Cloning into '/root/.nvm'... remote: Enumerating objects: 290, done. remote: Counting objects: 100% (290/290), done. remote: Compressing objects: 100% (257/257), done. remote: Total 290 (delta 34), reused 111 (delta 20), pack-reused 0 Receiving objects: 100% (290/290), 163.37 KiB | 2.37 MiB/s, done. Resolving deltas: 100% (34/34), done. => Compressing and cleaning up git repository => Appending nvm source string to /root/.bashrc => Appending bash_completion source string to /root/.bashrc npm WARN npm npm does not support Node.js v10.24.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9. npm WARN npm You can find the latest version at https://nodejs.org/ => You currently have modules installed globally with `npm`. These will no => longer be linked to the active version of Node when you install a new node => with `nvm`; and they may (depending on how you construct your `$PATH`) => override the binaries of modules installed with `nvm`: /usr/local/lib `-- n.@0.0.2 => If you wish to uninstall them at a later point (or re-install them under your => `nvm` Nodes), you can remove them from the system Node as follows: $ nvm use system $ npm uninstall -g a_module => Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
これでnvmが使用できると思ったので、下記コマンドを実行
nvm install node --reinstall-packages-from=node bash: nvm: command not found root@1fa7dccc0fba:/work# nvm -v bash: nvm: command not found
補足情報(FW/ツールのバージョンなど)
macOS Big Sur
バージョン 11.2.1
Docker
バージョン 20.10.2
docker-compose
バージョン 1.27.4
お力添えいただけると助かります。よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー