エンジニア初心者の投稿であるため、間違っている箇所が多くあるかと思います。
何かお気づきの点がありましたらご教授いただけると幸いです。
はじめに
Macにパソコンを変えてからNodo.jsを使用したかったため、Node.jsをインストールしようとコマンドと戦った出来事をまとめます。
やってみたこと
ターミナルで以下のコマンドを入力した。
terminal
$ nodebrew install-binary stable
以下のエラーがコマンドさんから返ってきた。
terminal
Fetching: https://nodejs.org/dist/v20.12.2/node-v20.12.2-darwin-arm64.tar.gz
Warning: Failed to open the file
Warning: /Users/ユーザー名/.nodebrew/src/v20.12.2/node-v20.12.2-darwin-arm64.tar
Warning: .gz: No such file or directory
curl: (23) Failure writing output to destination
インストール成功までの手順
上記のエラー文を読んでみるとディレクトリがないとのエラーであったので、ディレクトリを作成することにした。
下記のコマンドを実行する。
terminal
$ mkdir -p ~/.nodebrew/src
インストールされたことを確認したら、nodeのバージョンを確認する。
terminal
$ node -v
ここで新たなエラーが発生…。
terminal
zsh: command not found: node
nodebrewがパスを通せていないことが問題であったので、パスを通した。
terminal
$ echo "export PATH=$HOME/.nodebrew/current/bin:$PATH" >> ~/.zprofile
これでやっとnpmが使える…。
パスの通し忘れには注意したいと思った今日この頃です。
参考文献