File tree 4 files changed +42
-2
lines changed
test/addons/node-module-version
4 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -2406,8 +2406,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
2406
2406
char errmsg[1024 ];
2407
2407
snprintf (errmsg,
2408
2408
sizeof (errmsg),
2409
- " Module version mismatch. Expected %d, got %d." ,
2410
- NODE_MODULE_VERSION, mp->nm_version );
2409
+ " The module '%s'"
2410
+ " \n was compiled against a different Node.js version using"
2411
+ " \n NODE_MODULE_VERSION %d. This version of Node.js requires"
2412
+ " \n NODE_MODULE_VERSION %d. Please try re-compiling or "
2413
+ " re-installing\n the module (for instance, using `npm rebuild` or"
2414
+ " `npm install`)." ,
2415
+ *filename, mp->nm_version , NODE_MODULE_VERSION);
2411
2416
2412
2417
// NOTE: `mp` is allocated inside of the shared library's memory, calling
2413
2418
// `uv_dlclose` will deallocate it
Original file line number Diff line number Diff line change
1
+ #include < node_version.h>
2
+ #undef NODE_MODULE_VERSION
3
+ #define NODE_MODULE_VERSION 42
4
+ #include < node.h>
5
+
6
+ namespace {
7
+
8
+ inline void Initialize (v8::Local<v8::Object> exports,
9
+ v8::Local<v8::Value> module,
10
+ v8::Local<v8::Context> context) {
11
+ }
12
+
13
+ }
14
+
15
+ NODE_MODULE_CONTEXT_AWARE (binding, Initialize)
Original file line number Diff line number Diff line change
1
+ {
2
+ 'targets' : [
3
+ {
4
+ 'target_name' : 'binding' ,
5
+ 'defines' : [ 'V8_DEPRECATION_WARNINGS=1' ],
6
+ 'sources' : [ 'binding.cc' ]
7
+ }
8
+ ]
9
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ require ( '../../common' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+
6
+ const re = new RegExp (
7
+ 'was compiled against a different Node.js version using\n' +
8
+ 'NODE_MODULE_VERSION 42. This version of Node.js requires\n' +
9
+ `NODE_MODULE_VERSION ${ process . versions . modules } .` ) ;
10
+
11
+ assert . throws ( ( ) => require ( './build/Release/binding' ) , re ) ;
You can’t perform that action at this time.
0 commit comments