tojocky / node-printer

Native node.js printer
1.51k stars 436 forks source link

npm install - The module was compiled against a different Node.js version #301

Open Slos opened 3 years ago

Slos commented 3 years ago

Looks like this package is always being compiled against the wrong node version, what is going on?

This printer packages has been annoying me for the past 3 years, I don't know what I am doing wrong but I always have problems with this package.

Out of my 50+ dependencies this is the only one which is busting my balls, aaarrgghhhhg!

nvm use 11.2.0 Now using node v11.2.0 (npm v6.4.1) node -v v11.2.0 which node /Users/*******/.nvm/versions/node/v11.2.0/bin/node npm install node app.js Error: The module '/Users/**********/dev/zdeapp/node_modules/printer/lib/node_printer.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 79. This version of Node.js requires NODE_MODULE_VERSION 67. Please try re-compiling or re-installing the module (for instance, usingnpm rebuildornpm install). at Object.Module._extensions..node (internal/modules/cjs/loader.js:751:18) at Module.load (internal/modules/cjs/loader.js:620:32) at tryModuleLoad (internal/modules/cjs/loader.js:560:12) at Function.Module._load (internal/modules/cjs/loader.js:552:3) at Module.require (internal/modules/cjs/loader.js:658:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (/Users/********/dev/zdeapp/node_modules/printer/lib/printer.js:10:22) at Module._compile (internal/modules/cjs/loader.js:722:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10) at Module.load (internal/modules/cjs/loader.js:620:32)

now trying with another node version:

sudo rm -rf node_modules/ nvm use v14.9.0 node -v v14.9.0 npm install node app.js Error: The module '/Users/filipschlosser/dev/zdeapp/node_modules/printer/lib/node_printer.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 79. This version of Node.js requires NODE_MODULE_VERSION 83. Please try re-compiling or re-installing the module (for instance, usingnpm rebuildornpm install). at Object.Module._extensions..node (internal/modules/cjs/loader.js:1126:18) at Module.load (internal/modules/cjs/loader.js:940:32) at Function.Module._load (internal/modules/cjs/loader.js:781:14) at Module.require (internal/modules/cjs/loader.js:964:19) at require (internal/modules/cjs/helpers.js:88:18) at Object.<anonymous> (/Users/filipschlosser/dev/zdeapp/node_modules/printer/lib/printer.js:10:22) at Module._compile (internal/modules/cjs/loader.js:1075:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10) at Module.load (internal/modules/cjs/loader.js:940:32) at Function.Module._load (internal/modules/cjs/loader.js:781:14)

henriquegranatto commented 3 years ago

I am experiencing the same problem here. I've tried all the possible solutions I found on the internet and nothing worked.

I mainly see solutions like this: https://stackoverflow.com/questions/46384591/node-was-compiled-against-a-different-node-js-version-using-node-module-versio

But it never works.

hgarcia commented 3 years ago

version 0.4.0 have been compiled against node v13.3.0 that solved the problem for me.

shabanbx commented 3 years ago

latest version of electron gives this problem so the solution is downgrade electron to 6.1.7 also downgrade global electron to v 6.1.7 then

./node_modules/.bin/electron-rebuild

If you have trouble on Windows, try:

.\node_modules.bin\electron-rebuild.cmd

then your printer will run fine