LoginSignup
1
0
記事投稿キャンペーン 「2024年!初アウトプットをしよう」

npm installできないときの解決策②(ChatGPT)

Last updated at Posted at 2024-01-29

1. 問題

npm installできないときの解決策①(元の環境に一致させる)の続き。
まだインストールできないPackageがあるようだ。
なんか長いエラー文が出てきたけど、これでどうやって「何がインストールできないのか」と「その原因」がわかるんだろう?

xxxx@xxxx ~/pj/nodebird (master)
$ npm ci

> fsevents@1.2.11 install C:\xxxx\xxxx\pj\nodebird\node_modules\fsevents
> node-gyp rebuild


C:\xxxx\xxxx\pj\nodebird\node_modules\fsevents>if not defined npm_config_node_gyp (node "C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1051:16)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\xxxx\\xxxx\\AppData\\Roaming\\nvm\\v14.0.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\xxxx\xxxx\pj\nodebird\node_modules\fsevents
gyp ERR! node -v v14.0.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

> core-js@2.6.11 postinstall C:\xxxx\xxxx\pj\nodebird\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> bcrypt@3.0.7 install C:\xxxx\xxxx\pj\nodebird\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v83-win32-x64-unknown.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.7 and node@14.0.0 (node-v83 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! find VS 
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1051:16)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\xxxx\\xxxx\\AppData\\Roaming\\nvm\\v14.0.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\xxxx\\xxxx\\pj\\nodebird\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\xxxx\\xxxx\\pj\\nodebird\\node_modules\\bcrypt\\lib\\binding" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd C:\xxxx\xxxx\pj\nodebird\node_modules\bcrypt
gyp ERR! node -v v14.0.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\xxxx\xxxx\pj\nodebird\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\xxxx\xxxx\pj\nodebird\node_modules\bcrypt\lib\binding --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\xxxx\xxxx\pj\nodebird\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1051:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
node-pre-gyp ERR! System Windows_NT 10.0.19045
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\xxxx\\xxxx\\pj\\nodebird\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\xxxx\xxxx\pj\nodebird\node_modules\bcrypt
node-pre-gyp ERR! node -v v14.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok 
Failed to execute 'C:\Program Files\nodejs\node.exe C:\xxxx\xxxx\AppData\Roaming\nvm\v14.0.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\xxxx\xxxx\pj\nodebird\nodellback-to-build --module=C:\xxxx\xxxx\pj\nodebird\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\xxxx\xxxx\pj\nodebire_abi_napi=napi --napi_build_version=0 --node_napi_labeld\node_modules\bcrypt\lib\binding --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@3.0.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\xxxx\xxxx\AppData\Roaming\npm-cache\_logs\2024-01-25T07_41_27_158Z-debug.log

2. 環境

node 14
npm 6.14.4
Windows 10

3. 解決

Chat GPTに聞いて、bcryptfseventsというPackageにインストールエラーが起きていることが分かった。
Visual Studioのインストールやnodenpmのアップデートなどの解決策も教えてもらった。

4. 詳細

以下はChatGPTに質問する手順である。

4.1 エラーをコピペ

エラー内容は同上。

4.2 質問

エラーをコピペしたら引き続き分からないことを聞く。
以下は私の質問とChatGPTの回答。ChatGPTの回答は適当に編集した。

エラーの説明と解決策を教えて。

bcryptモジュールのインストール中に、Visual Studioの設定やインストールが正しく行われていないようです。
以下は問題を解決するための手順です:

  1. Viisual Studioのインストール
  2. Visual Studioの設定
  3. Node.jsnpmの更新
  4. (npm) インストールを再試行

4.3 追加質問

自分でエラーを読んでみたところ、fseventsのインストールにも何か問題があるようだけど、
それについてはChatGPTが何も言わなかったので、追加質問してみた。

fseventsもエラーになってない?

はい、fseventsモジュールのインストールもエラーが発生しているようです。

このモジュールは通常、Mac OSで使用されることが多く、Windowsでの利用時に問題が生じることがあります。

fseventsは通常、ファイルシステムの変更を監視するために使用されるライブラリで、Windows上では動作しないことがあります。以下はその対処法です:

  1. fseventsをスキップする
  2. Windows用の代替パッケージを使用する

5. 次の記事

・エラーの原因を自ら把握してみたい。
 →npm installできないときの解決策③(Stack Trace)

6. まとめ

npm installエラーの内容が分からなかったら、ChatGPTにエラーの説明と解決策を聞けばいい。
具体的には教えてくれないが、ある程度状況の把握には役に立つ。

7. 感じたこと

期待したよりは回答が具体的ではなかった。ChatGPTに100%頼れるのはまだ先の話のようだ。
そもそもChatGPTが本当のことを言っているか信じがたい。
まあ、自分の質問方法がよくなかったかも知れないけど。
ProgrammingのError Troubleshootingには「解決策へのヒントを得る」くらいの用途でよさそうだ。
やはり今の私には基礎をしっかり積んで、正道(自分でエラーの原因を特定して解決)で行くのが一番安心できる。
実務ではChatGPTにエラーをコピペして何か聞くこと自体が禁止されている可能性もあるし。

8. 参考

ChatGPT 3.5

1
0
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
1
0