LoginSignup
2
2

More than 1 year has passed since last update.

nodenvを使ってnode環境を作る

Last updated at Posted at 2020-08-12

はじめに

ちょっと仕事で AWS Lamdbaを使うことになりそうなので、いまさらながらお勉強。
WSL2のUbuntuに開発環境を作って、試してみようと思います。

環境

Windows 10
WSL2
Ubuntu 20.04 LTS

nodenvをインストールする

git clone で必要なファイルを取得します。

git clone https://github.com/nodenv/nodenv.git ~/.nodenv
git clone https://github.com/nodenv/node-build.git ~/.nodenv/plugins/node-build

nodenvにパスを通します。

echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(nodenv init -)"' >> ~/.profile
source ~/.profile

Node.jsをインストールする

インストール可能なバージョン一覧を取得し、表示されたバージョンを指定してインストール。
ここでは最新のLTSを選択

nodenv install --list
nodenv install 12.18.3

利用するNode.js のバージョンを指定する
localを指定することで、コマンド実行した配下のディレクトリで、該当バージョンを利用することができます。

nodenv local 12.18.3

以下の通りで、全体で利用するバージョンを指定することもできます。

nodenv global 12.18.3

最後にバージョン確認。指定したバージョンが表示されればOK

node -v

さいごに

これで、準備はできたので、次はServerlessFrameworkだ。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2