sudo apt update
sudo apt install nodejs
sudo apt install npm
sudo npm cache clean
sudo npm install -g n
sudo n stable
sudo npm update -g npm
npm install -g [package name]
-g
はグローバルインストールを意味する。
汎用的なパッケージは -g
をつけてインストールする。
あるプロジェクトのみで使用したいパッケージをインストールしたい場合は、
プロジェクトのディレクトリに移動し -g
をつけずにコマンドを実行する。