0
0

More than 3 years have passed since last update.

【Windows】node-gyp ERRで困ったときの対処法

Posted at

electronでディープリンク(Custom URL Schema)実装時にelectron-deeplink を使おうと思ったのですが、そこでnode-gypのエラーが出て躓いたので、その時の対処法をメモします。
ディープリンクについてはelectron-deeplinkを使って実装したら(少なくとも開発環境では)簡単にできましたので割愛します。

結論

Python や Visual C++ といった必要なものをインストールする

エラー内容

yarn add electron-deeplinkしたところ、

gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration

とか、Pythonをインストールした後も

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.

という感じで

参考

nodejs/node-gyp
Windowsでnpm installしてnode-gypでつまずいた時対処方法

ERR! find Pythonと出た場合のPythonインストール

powershell
python

と打つと、Python公式ページが開くのでそこからダウンロード&インストール
(バージョンはnodejs/node-gypから対応してるものを選ぶように)

ぼくの場合はこれでも「VSが見つからん!」と怒られたのでwindows-build-toolsを使いました。

bash
yarn add global windows-build--tools

で、成功すれば下記の表示が出るので、vs_BuildTools.exeを起動します

Downloaded vs_BuildTools.exe. Saved to C:\Users\{ユーザ名}\.windows-build-tools\vs_BuildTools.exe.
powershell
PS C:\Users\{ユーザ名}> .\.windows-build-tools\vs_BuildTools.exe

起動できると下記のような画面が出ます。
ぼくの場合とりあえず一度デフォルトのままインストールしたものの、再度modifyをしてインストールしたので表示が違うかもしれません
Visual C++ build toolsにチェックを入れて、Install or Modify をクリック

image.png
image.png

electron-deeplink インストールし直す

bash
yarn add electron-deeplink
#なんやかんや
$ electron-builder install-app-deps
  • electron-builder  version=22.9.1
  • loaded configuration  file=C:\Users\{path-to-project}\electron-builder.yml
  • rebuilding native dependencies  dependencies=electron-deeplink@1.0.6 platform=win32 arch=x64
  • rebuilding native dependency  name=electron-deeplink version=1.0.6
Done in 36.12s.

これで解決
ディープリンクも簡単に実装できました。

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