Node.jsをUbuntuにローカルインストール
nvm
Node.jsをダウンロードしてインストールできるツール。
バージョンの切替方法は以下
qiita.com
npm
javascriptパッケージをインストールするツール。
インストール
以下を実行
git clone https://github.com/creationix/nvm.git ~/.nvm source .nvm/nvm.sh nvm install 10.15.3 #最新版
設定
bashrcもしくはbash_profileに以下を追記
if [[ -s ~/.nvm/nvm.sh ]]; then source ~/.nvm/nvm.sh fi
確認
hello.jsを作成
console.log("hello node.js")
hello.jsを実行
$ node hello.js hello node.js