Thursday 12 November 2020

Incorrect NODE_MODULE_VERSION when using ava

I use ava 3.13.0 with node 14.15.0 and Electron 10.1.5 and nodegit 0.27.0. and spectron.

I use ava with spectron to start my app, do some tests and stop it. All of this works - including functions which use nodegit in my app.

In addition to the tests described above I made also a pure non-Electron test file and import nodegit directly.

 import * as nodegit from 'nodegit';

Executing this test now via ava returns this:

node_modules\.pnpm\nodegit@0.27.0\node_modules\nodegit\build\Release\nodegit.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 82. This version of Node.js requires
NODE_MODULE_VERSION 83. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Module._extensions..node (internal/modules/cjs/loader.js:1122:18)

Where exactly does version 82 come from? I only have nodejs 14.15.0 installed, which uses version 83 as expected. Why does ava think the version is a mismatch where it works actually in my app? This is how my package.json looks like:

  "devDependencies": {
    "ava-ts": "0.25.2",
  },
  "scripts": {
    "ava-ts": "node_modules/.bin/ava-ts",
     ...
  },
  "ava": {
    "files": [
      "*.ts"
    ],
    "extensions": [
      "ts"
    ],
    "require": [
      "ts-node/register"
    ],
    "nodeArguments": [
      "--napi-modules",
      "--experimental-modules"
    ]
  },

I built nodegit myself and in the config.gypi file it even refers to:

    "node_module_version": 83,

I made a super simple reproducible example: https://github.com/Githubber2021/node_module_version-issue

% node --version
14.15.0
% npm install
% npm run ava
... error

Can anyone explain me if this a bug or where version 82 comes from?



from Incorrect NODE_MODULE_VERSION when using ava

No comments:

Post a Comment