✔︎Pickup

windowsでnode-gypを使おうとしたらエラーが発生しました。

解決策が見つかりましたので共有します。

node-gyp configure

※gyp ERR!発生しました

gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.14.0 | win32 | x64
gyp info find Python using Python version 3.10.2 found at "C:\Users\admin\AppData\Local\Programs\Python\Python310\python.exe"
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 find a version of Visual Studio 2017 or newer to use
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:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
gyp ERR! stack     at C:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
gyp ERR! stack     at C:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14gyp ERR! stack     at C:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16
gyp ERR! stack     at C:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Users\admin\AppData\Roaming\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (node:child_process:406:5)
gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\admin\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd C:\Users\admin\Desktop\multiCPU
gyp ERR! node -v v16.14.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok

エラーのコメントを読んでみると、Could not find any Visual Studio installation to useがErrorになっています。

解決策はここに書いてありました。

https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules

解決策①Microsoftのwindows-build-toolsを使用する

管理者権限でPowerShellを起動して、以下のコマンドを実行します

npm install -g windows-build-tools

詳細は下記の記事を参照ください

解決策②Visual C ++ビルド環境のインストールする

Visual Studioビルドツール(「VisualC ++ビルドツール」ワークロードを使用)または
Visual Studio 2017コミュニティ(「C ++を使用したデスクトップ開発」ワークロードを使用)をインストールする

Python 2.7をインストールする(v3.x.xサポートされていません)

cmdを起動し、以下のコマンドを実行します

npm config set python python2.7

npm config set msvs_version 2017

ブログ村リンク
ポチッと押してね!フォローもしてね!

ブログランキング・にほんブログ村へ
にほんブログ村
おすすめの記事