😺

node 環境構築

2022/03/02に公開

nvmインストール

 ~/W/d/dandyyy   *…  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--   100 15037  100 15037    0     0  64814      0 --:--:-- --:--:-- --:--:-- 64814
=> nvm is already installed in /Users/tanokentaro/.nvm, trying to update using git
=> => Compressing and cleaning up git repository

=> nvm source string already in /Users/tanokentaro/.bash_profile
=> bash_completion source string already in /Users/tanokentaro/.bash_profile
=> 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`:

/Users/tanokentaro/.nodebrew/node/v14.0.0/lib
├── @vue/cli@4.5.15
=> 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

パスを通す(shell起動時に使用するツールのパスを読み込むように設定する)

code ~/.bash_profile

.bash_profile

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

ターミナル を更新(ターミナル再起動でもOK)

source ~/.bash_profile

エラー

~/.bash_profile (line 4): Unsupported use of '='. In fish, please use 'set PATH "/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"'.
from sourcing file ~/.bash_profile
source: Error while reading file '/Users/tanokentaro/.bash_profile'

fishなので、書き方が違うと怒られる
人まず前からグローバル設定しててnodejs使えるのでスルー

以下まで実施

 ~/W/d/dandyyy   *…  node -v                         2022-02-16 13:55:51
v14.0.0

Discussion