I have test.js
:
const { createCanvas, loadImage } = require('canvas');
console.log('hi');
launch.json
...
{
"name": "test script",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/test.js",
"console": "integratedTerminal"
},
...
When I run test script
in the VSCode debugger I get
internal/modules/cjs/loader.js:1144
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: The module '/Users/me/Documents/gift_registry_business_idea/backend/node_modules/canvas/build/Release/canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. 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 Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/Users/dashiellbarkhuss/Documents/gift_registry_business_idea/backend/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
code: 'ERR_DLOPEN_FAILED'
}
However, test.js
works fine if I run node test.js
in the terminal or if I run this in launch.json
, changing node to nodemon
...
{
"name": "test script",
"type": "node",
"request": "launch",
"runtimeExecutable": "nodemon",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/test.js",
"console": "integratedTerminal"
},
...
Deleting node_modules and runing npm rebuild
or npm install
didn’t work.