src: update module version mismatch error message
Fixes: https://github.com/nodejs/node/issues/8379 PR-URL: https://github.com/nodejs/node/pull/8391 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
07b54ec4ca
commit
a6e1be4a4e
@ -2406,8 +2406,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
|
|||||||
char errmsg[1024];
|
char errmsg[1024];
|
||||||
snprintf(errmsg,
|
snprintf(errmsg,
|
||||||
sizeof(errmsg),
|
sizeof(errmsg),
|
||||||
"Module version mismatch. Expected %d, got %d.",
|
"The module '%s'"
|
||||||
NODE_MODULE_VERSION, mp->nm_version);
|
"\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
|
// NOTE: `mp` is allocated inside of the shared library's memory, calling
|
||||||
// `uv_dlclose` will deallocate it
|
// `uv_dlclose` will deallocate it
|
||||||
|
15
test/addons/node-module-version/binding.cc
Normal file
15
test/addons/node-module-version/binding.cc
Normal file
@ -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)
|
9
test/addons/node-module-version/binding.gyp
Normal file
9
test/addons/node-module-version/binding.gyp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
'targets': [
|
||||||
|
{
|
||||||
|
'target_name': 'binding',
|
||||||
|
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
|
||||||
|
'sources': [ 'binding.cc' ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
11
test/addons/node-module-version/test.js
Normal file
11
test/addons/node-module-version/test.js
Normal file
@ -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);
|
Loading…
x
Reference in New Issue
Block a user