hbenl / vscode-mocha-test-adapter

Mocha Test Adapter for the VS Code Test Explorer
MIT License
91 stars 31 forks source link

Not using correct node version #252

Open zachfey opened 7 months ago

zachfey commented 7 months ago

I've updated from Node v16 to Node v20 and I cannot get Mocha Test Explorer to use the proper version of node. When opening the explorer, I get the following error:

Error: The module '/home/zach/dev/phalanx/nodejs/cmd/phalanx/node_modules/pg-query-native/build/Release/pg-query.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 115. This version of Node.js requires
NODE_MODULE_VERSION 108. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at bindings (/home/zach/dev/phalanx/nodejs/cmd/phalanx/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/home/zach/dev/phalanx/nodejs/cmd/phalanx/node_modules/pg-query-native/index.js:1:34)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.require.extensions.<computed> [as .js] (/home/zach/dev/phalanx/nodejs/cmd/phalanx/node_modules/ts-node/src/index.ts:1608:43) {
  code: 'ERR_DLOPEN_FAILED'
}

I believe it is because the test explorer is running with Node v16 (which was shipped with my version of VS Code), whereas my app is now compiled with Node v20.

I've tried ensuring NVM's node path is exported in my path with export NODE_PATH='which node' and attempted pointing MocaTestExplorer to it by adding "mochaExplorer.nodePath": "$HOME/.nvm/versions/node/v20.11.1/bin/node", in settings.json, but I keep getting the same error message.

hbenl commented 7 months ago

attempted pointing MocaTestExplorer to it by adding "mochaExplorer.nodePath": "$HOME/.nvm/versions/node/v20.11.1/bin/node", in settings.json

That should have fixed it. You could try turning on diagnostic logging, it should contain a message "[DEBUG] Using nodePath: ..." showing which path it uses.