summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/node.cc b/src/node.cc
index 77e6a5826e..853e0aa796 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -180,6 +180,9 @@ static const char* trace_enabled_categories = nullptr;
std::string icu_data_dir; // NOLINT(runtime/string)
#endif
+// N-API is in experimental state, disabled by default.
+bool load_napi_modules = false;
+
// used by C++ modules as well
bool no_deprecation = false;
@@ -2463,15 +2466,25 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
}
if (mp->nm_version != NODE_MODULE_VERSION) {
char errmsg[1024];
- snprintf(errmsg,
- sizeof(errmsg),
- "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);
+ if (mp->nm_version == -1) {
+ snprintf(errmsg,
+ sizeof(errmsg),
+ "The module '%s'"
+ "\nwas compiled against the ABI-stable Node.js API (N-API)."
+ "\nThis feature is experimental and must be enabled on the "
+ "\ncommand-line by adding --napi-modules.",
+ *filename);
+ } else {
+ snprintf(errmsg,
+ sizeof(errmsg),
+ "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
@@ -3537,6 +3550,7 @@ static void PrintHelp() {
" --trace-deprecation show stack traces on deprecations\n"
" --throw-deprecation throw an exception on deprecations\n"
" --no-warnings silence all process warnings\n"
+ " --napi-modules load N-API modules\n"
" --trace-warnings show stack traces on process warnings\n"
" --redirect-warnings=path\n"
" write warnings to path instead of\n"
@@ -3709,6 +3723,8 @@ static void ParseArgs(int* argc,
force_repl = true;
} else if (strcmp(arg, "--no-deprecation") == 0) {
no_deprecation = true;
+ } else if (strcmp(arg, "--napi-modules") == 0) {
+ load_napi_modules = true;
} else if (strcmp(arg, "--no-warnings") == 0) {
no_process_warnings = true;
} else if (strcmp(arg, "--trace-warnings") == 0) {
@@ -4489,6 +4505,11 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
if (debug_enabled)
EnableDebug(&env);
+ if (load_napi_modules) {
+ ProcessEmitWarning(&env, "N-API is an experimental feature "
+ "and could change at any time.");
+ }
+
{
SealHandleScope seal(isolate);
bool more;