0

I upgraded my version of node. npm rebuild and deleting my node_modules directory does not seem to work for me to rebuild my C++ addons. I'm still getting this error:

Error: The module '[...]/node_modules/node-expat/build/Release/node_expat.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 46. This version of Node.js requires
NODE_MODULE_VERSION 51. Please try re-compiling or re-installing

I think it would be nice to just blow away all the C++ addons (or maybe just this one if you could target them) which would likely solve my problem. Any quick and easy way to do this?

cgsd
  • 1,242
  • 2
  • 13
  • 25

2 Answers2

1

Node recently released version 7.7, and very soon after discovered that there was a bug in it that prevented all native modules from being compiled.

Shortly they released a patch, v7.7.1, which should fix that issue. I'm guessing you upgraded to 7.7, so updating your install to 7.7.1 should solve this for ya.

rossipedia
  • 56,800
  • 10
  • 90
  • 93
0

in case npm update won't help (that means, that for some reason it won't recompile the module, as it is supposed to do), go to the module directory and manually recompile with make clean && make or npm rebuild / npm rb. that's the common way of fixing such version conflicts - or at least obtaining more detailed information about the reason. removing and reinstalling the problematic module(s) might also be worth a try. without V8 nodeJS can do way less, than while it's loaded (removing it might altogether only cripple down the possibilities; would not suggest to do so, despite the original question).

The documentation at npmjs.com clearly states:

This is useful when you install a new version of node, and must recompile all your C++ addons with the new binary.

... so that's the default procedure, in case of an update.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216