I use nw.js and when trying to connect the canvas module (node-canvas), this error appears. Installing a different version of node/canvas didn't help. The error appears when
require('canvas')
Error image:
Error
Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\N:\BOTSer\Protocol\node_modules\canvas\build\Release\canvas.node
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1224:18)
at Module.load (node:internal/modules/cjs/loader:999:32)
at Function.Module._load (node:internal/modules/cjs/loader:846:12)
at Module.require (node:internal/modules/cjs/loader:1023:19)
at require (node:internal/modules/cjs/helpers:97:18)
at Object.<anonymous> (N:\BOTSer\Protocol\node_modules\canvas\lib\bindings.js:3:18)
at Module._compile (node:internal/modules/cjs/loader:1121:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1179:10)
at Module.load (node:internal/modules/cjs/loader:999:32)
at Function.Module._load (node:internal/modules/cjs/loader:846:12)
```
That module requires a native build that is compatible with your global install of Node.js. If the version of Node in NW.js doesn't match your global install, then the built binary will not work with it. Things always work better when you switch your global Node.js install version to match what is built into NW.js. You can use nvm-windows
or nvm
to control your global Node version, just be sure to uninstall Node.js first before using a Node Version Manager so you don't have two conflicting global installs. You can check the Node.js version in NW.js by running console.log(process.version);
.
If my assumption is correct then:
node_modules
and package-lock.json
npm install
in your project and try running it againThough I'm very confused as to why you would be using the native canvas
module with NW.js. Why are you packaging an entire browser with your application that has a canvas built in, and then pulling in a second tool and using it instead? Just use the browser's canvas.