LoginSignup
0
0

More than 1 year has passed since last update.

[Electron] C++ addon (Native Node Module) を他PCに展開したとき、"Specified module could not be found" で動かない

Posted at

前段

ぼく「Electronでアプリ作ったよ!」
とも「module not found とか言われて動かないよ〜」
ぼく「はっ!?」

と、なったときの対処方法です。

チェック項目

:white_check_mark: 対象Nodeモジュール(hogehoge.node)は、ちゃんと存在している?

対象Nodeモジュールが存在しないときは、Webpackに失敗しているのかも。

*.nodeを読み込むルールを確認します。

webpack.config.js
{
  module: {
    rules: [
      {
        test: /\.node$/,
        loader: "node-loader",
        options: {
          name: "[name].[ext]"
        }
      }
    ]
  }
}

:white_check_mark: 対象Nodeモジュール(hogehoge.node)に必要なDLLは入ってる?

dumpbin /dependents hogehoge.node として、必要なDLLをチェックします。

    kernel32.dll
    bcrypt.dll
    user32.dll
    advapi32.dll
    VCRUNTIME140.dll
    VCRUNTIME140_1.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-utility-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-conio-l1-1-0.dll

VCRUNTIME140.dll は、VC++再頒布可能パッケージをインストールしないといけないやつです。

ビルドしたPCの %VCToolsRedistDir% の下に vc_redist.*.exe というファイルがあるので、実行するPCへインストールします。

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