Permalink
Browse files

src: update module version mismatch error message

Fixes: #8379
PR-URL: #8391
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information...
jasnell committed Sep 2, 2016
1 parent 96b501d commit 1fda657cac9e1de5992efb02ec9be46bb1c745d9
@@ -2406,8 +2406,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"Module version mismatch. Expected %d, got %d.",
NODE_MODULE_VERSION, mp->nm_version);
"The module '%s'"
"\nwas compiled against a different Node.js version using"
"\nNODE_MODULE_VERSION %d. This version of Node.js requires"
"\nNODE_MODULE_VERSION %d. Please try re-compiling or "
"re-installing\nthe module (for instance, using `npm rebuild` or"
"`npm install`).",
*filename, mp->nm_version, NODE_MODULE_VERSION);
// NOTE: `mp` is allocated inside of the shared library's memory, calling
// `uv_dlclose` will deallocate it
@@ -0,0 +1,15 @@
#include <node_version.h>
#undef NODE_MODULE_VERSION
#define NODE_MODULE_VERSION 42
#include <node.h>
namespace {
inline void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context) {
}
}
NODE_MODULE_CONTEXT_AWARE(binding, Initialize)
@@ -0,0 +1,9 @@
{
'targets': [
{
'target_name': 'binding',
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
'sources': [ 'binding.cc' ]
}
]
}
@@ -0,0 +1,11 @@
'use strict';
require('../../common');
const assert = require('assert');
const re = new RegExp(
'was compiled against a different Node.js version using\n' +
'NODE_MODULE_VERSION 42. This version of Node.js requires\n' +
`NODE_MODULE_VERSION ${process.versions.modules}.`);
assert.throws(() => require('./build/Release/binding'), re);

0 comments on commit 1fda657

Please sign in to comment.