3

I am now getting the following error when I run my node app. It has only occurred after I upgraded from node 8.12.0 to node 10.13.0 (which is now "recommended for most users"). The problem seems to relate to node-expat, which I don't use directly but which is a dependency of xml2json (which I do use directly).

/root/workspace/myapp/node_modules/bindings/bindings.js:88
        throw e
        ^

Error: The module '/root/workspace/myapp/node_modules/node-expat/build/Release/node_expat.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (module.js:682:18)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at bindings (/root/workspace/myapp/node_modules/bindings/bindings.js:81:44)
    at Object.<anonymous> (/root/workspace/myapp/node_modules/node-expat/lib/node-expat.js:4:32)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)

What do I need to do to fix this? Yes, I have completely removed node_modules and done npm install as per this thread... doesn't help.

drmrbrewer
  • 11,491
  • 21
  • 85
  • 181
  • 1
    Try to also delete `package-lock.json` – Gabriel Bleu Nov 13 '18 at 16:35
  • @GabrielBleu there is no `package-lock.json` – drmrbrewer Nov 13 '18 at 16:59
  • Did you try `npm cache clean -f` (and reinstall everything)? There were multiple issues with npm registry in recent weeks. See the [incident](https://status.npmjs.org/incidents/) reports. – lependu Nov 13 '18 at 17:02
  • I wonder whether it has something to do with this commit made 3 months ago to `node-expat`: https://github.com/astro/node-expat/commit/822197d0a0f1b69e4a2cd0f4010d54b9c66d0ec3. The `xml2json` package is still referencing version `2.3.16` of `node-expat` in its `package-lock.json` (see https://github.com/buglabs/node-xml2json/blob/master/package-lock.json). – drmrbrewer Nov 13 '18 at 17:06
  • @lependu that doesn't help either. Re my comment just above... could it be that? How do I force a different version of `node-expat` on `xml2json` when `xml2json` isn't my own module... I'm just `require`ing that as a dependency in my node app (and `package.json`)? – drmrbrewer Nov 13 '18 at 17:10
  • @drmrbrewer double check, node 8.12.0 ships with npm 6.4.1 which creates a package-lock.json every time you install. – Gabriel Bleu Nov 13 '18 at 17:15
  • @GabrielBleu definitely no `package-lock.json` :-) ... I've disabled it with `npm config set package-lock false` – drmrbrewer Nov 13 '18 at 17:18
  • I am afraid you can't tweak 3rd party module dependency. Maybe `node-gyp rebuild` can help. – lependu Nov 13 '18 at 18:21
  • I have no idea why it is working now, but it is :-/ Seems that several iterations of doing `nvm uninstall 10.13.0` / `nvm install 10.13.0` / `rm -fr node_modules` / `npm cache clean -f` / `npm install` has resulting in a working installation. No idea why it wasn't working straight away. – drmrbrewer Nov 13 '18 at 19:00

0 Answers0