【问题标题】:Windows 10, existing binding.node file cannot be found when running jestWindows 10,运行 jest 时找不到现有的 binding.node 文件
【发布时间】:2018-04-09 08:56:07
【问题描述】:

在 appveyor 上和作为 virtualbox 运行 Windows 10 时,我在为我的电子应用程序运行开玩笑测试时遇到了同样的错误。

 The specified module could not be found.
    \\?\C:\Users\User\peruse\app\node_modules\ref\build\Release\binding.node
      Error: The specified module could not be found.
      \\?\C:\Users\User\peruse\app\node_modules\ref\build\Release\binding.node
      at Runtime.requireModule (node_modules/jest-runtime/build/index.js:263:31)
      at bindings (app/node_modules/bindings/bindings.js:76:44)
      at Object.<anonymous> (app/node_modules/ref/lib/ref.js:5:47)

(https://ci.appveyor.com/project/joshuef/peruse/build/1.0.733/job/fwflo19to9rvt085#L4664)

问题是......文件本身存在,通过运行确认:

dir  \\?\C:\Users\User\peruse\app\node_modules\ref\build\Release\binding.node 

导致:

-a----         4/9/2018   1:44 AM         157696 binding.node

应用程序本身运行良好(它是一个电子应用程序,通过 webpack 编译)。只有在针对本机库运行测试时,我才会收到此错误。并且仅在 Windows 中。 (osx/linux 测试运行良好。)

我尝试过重建,使用npm 而不是yarn,通过命令行重新安装 vs2017 工具...我在两个系统上都经常遇到这个错误(这是 一些东西 em>),但我不知道接下来要尝试什么......

Jest 正在从命令行运行。

Jest 是这样配置的:

module.exports = {
    verbose                : true,
    moduleFileExtensions   : ['js', 'jsx', 'json'],
    setupFiles   : ['raf/polyfill','<rootDir>/test/setup.js'],
    testPathIgnorePatterns : ['node_modules'],
    moduleDirectories      : ['app', 'test', 'node_modules', 'app/node_modules'],
    moduleNameMapper       : {
        "electron": "<rootDir>/mocks/electron.js",
        "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
        "<rootDir>/mocks/fileMock.js",
        "\\.(css|scss)$": "<rootDir>/mocks/fileMock.js",
        '^appPackage$'      : '<rootDir>/package.json',
        '^@actions(.*)$'    : '<rootDir>/app/actions$1',
        '^@components(.*)$' : '<rootDir>/app/components$1',
        '^@containers(.*)$' : '<rootDir>/app/containers$1',
        '^appConstants$'  : '<rootDir>/app/constants.js',
        '^@extensions(.*)$' : '<rootDir>/app/extensions$1',
        '^@logger$'     : '<rootDir>/app/logger.js',
        '^@reducers(.*)$'   : '<rootDir>/app/reducers$1',
        '^@store(.*)$'      : '<rootDir>/app/store',
        '^@utils(.*)$'      : '<rootDir>/app/utils$1'
    }
};

the appveyor config file is here.

任何要检查的指针/想法/事情 super 表示赞赏。如果需要更多代码说明,请告诉我。

提前致谢!

【问题讨论】:

  • 嘿@josh,我目前遇到同样的问题 - 你设法解决了吗?
  • 嘿@EvgenySorokin,很抱歉我们没有。一堆围绕各种文件夹结构选项的挖掘结果一无所获:(
  • @EvgenySorokin 有什么消息吗? Electron 和 Windows 也在这里卡住了。
  • @Nickensoul 不幸的是,没有,作为一种解决方法,我们停止模拟导致此错误的 ibm db 模块并模拟使用它的模块
  • @EvgenySorokin,同样。我们刚刚模拟了无法解析的原生模块。奇怪的事情。无论如何,感谢您的反馈!

标签: javascript node.js windows-10 electron jestjs


【解决方案1】:

我在 Windows 10 上使用 ibm_db 模块时遇到了类似的错误(但在 Linux Docker 容器中没有):

The specified module could not be found.
\\?\C:\_projects\projectName\node_modules\ibm_db\build\Release\odbc_bindings.node

  at Runtime._loadModule (node_modules/jest-runtime/build/index.js:572:29)
  at bindings (node_modules/bindings/bindings.js:112:48)

找到解决方案here

  1. IBM site 下载 odbc 驱动程序。您可能需要注册 为此在 IBM 工作。
  2. 只需解压即可安装此 odbc 驱动程序 您下载到某个文件夹的包的内容,例如 例如“C:\IBMDB2\CLIDRIVER\”
  3. 设置指向包含驱动程序的文件夹的 IBM_DB_HOME 环境变量。 ( 到 "C:\IBMDB2\CLIDRIVER\" 如果你使用了那个路径)
  4. 在“PATH”环境变量中添加“%IBM_DB_HOME%\bin”路径。
  5. 重新启动或退出/登录,以使对 PATH 的更改生效。
  6. 使用“npm install”重新安装包,因为所有这些环境变量仅在包安装阶段使用。

【讨论】:

    猜你喜欢
    • 2020-05-07
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    相关资源
    最近更新 更多