「npm install」を全てcmdで行ってはいけない話


いつものように本番環境ではどのように動くのか試したかったので、以下のコマンドを打つと

firebase deploy

update ~ npm i -g firebase-tools

的なことを書かれたのでいざ実行するとエラーが発生

npm i -g firebase-tools

npm ERR! The operation was rejected by your operating system.
npm ERR! It’s possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npmのエラーは厄介だからこれは時間がかかると思い、案の定2,3時間くらい時間を費やした。

要するに権限が無いよと言う意味。

色々調べてみると、本来ならC:\Program Files (x86)\nodejs(自分で設定したファイル名)\etcというフォルダがあるはずなのだが無かった。

なので、一度npmのバージョンアップデートしてみる。

npm i npm@latest

そうすると、無事インストールが完了しetcフォルダも作成された。

そして同じようにfirebase-toolsを実行すると同じようなエラーが発生😨

npm i -g firebase-tools

npm ERR! The operation was rejected by your operating system.
npm ERR! It’s possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

このことから、なんでもGitBashでインストールしてはいけないんだなと思った。

なので、Windowsの「Powershell」を「管理者として実行する」とfirebase-toolsをインストールしてみると無事インストールされた!

いや~長かった。

npmのエラーは嫌いです!

以上、「「npm install」を全てcmdで行ってはいけない話」でした!

良ければ、LGTM、コメントお願いします。

また、何か間違っていることがあればご指摘頂けると幸いです。

他にも初心者さん向けに記事を投稿しているので、時間があれば他の記事も見て下さい!!

Thank you for reading