summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/api/deprecations.md5
-rw-r--r--lib/internal/modules/cjs/loader.js7
-rw-r--r--test/message/async_error_sync_esm.out1
3 files changed, 11 insertions, 2 deletions
diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index 9773c4069f..7aeab5be7d 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -2451,12 +2451,15 @@ instead.
### DEP0130: Module.createRequireFromPath()
<!-- YAML
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/27951
+ description: Runtime deprecation.
- version: v12.2.0
pr-url: https://github.com/nodejs/node/pull/27405
description: Documentation-only.
-->
-Type: Documentation-only
+Type: Runtime
Module.createRequireFromPath() is deprecated. Please use [`module.createRequire()`][] instead.
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index e676d06fa9..27f8c8912a 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -860,7 +860,12 @@ function createRequireFromPath(filename) {
return makeRequireFunction(m);
}
-Module.createRequireFromPath = createRequireFromPath;
+Module.createRequireFromPath = deprecate(
+ createRequireFromPath,
+ 'Module.createRequireFromPath() is deprecated. ' +
+ 'Use Module.createRequire() instead.',
+ 'DEP0130'
+);
const createRequireError = 'must be a file URL object, file URL string, or ' +
'absolute path string';
diff --git a/test/message/async_error_sync_esm.out b/test/message/async_error_sync_esm.out
index f34628ef44..544916e248 100644
--- a/test/message/async_error_sync_esm.out
+++ b/test/message/async_error_sync_esm.out
@@ -5,3 +5,4 @@ Error: test
at async three (*fixtures*async-error.js:20:3)
at async four (*fixtures*async-error.js:24:3)
at async main (*message*async_error_sync_esm.mjs:7:5)
+(node:*) [DEP0130] DeprecationWarning: Module.createRequireFromPath() is deprecated. Use Module.createRequire() instead.