-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Closed
Description
- Version: 12.3.0
- Platform:
Linux localhost 4.19.0-5-amd64 #1 SMP Debian 4.19.37-3 (2019-05-15) x86_64 GNU/Linux
- Subsystem: Modules
Steps to reproduce
Save the following file as test.js
:
console.log(require.resolve("./test", { paths: "." }));
Run it:
node test.js
Expected Behavior
This output on stdout
:
/tmp/t1/test.js
Actual Behavior
In node 12.3.0 this is what I get:
internal/modules/cjs/loader.js:603
throw new ERR_INVALID_OPT_VALUE('options.paths', options.paths);
^
TypeError [ERR_INVALID_OPT_VALUE]: The value "." is invalid for option "options.paths"
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:13)
at Function.resolve (internal/modules/cjs/helpers.js:21:19)
at Object.<anonymous> (/tmp/t1/test.js:1:21)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
at internal/main/run_main_module.js:17:11
Observations
I get the expected behavior in Node 12.2.0, Node 10.14.2 and Node 8.15.0.
The documentation for require.resolve
has been at least as far back as Node 8 that an array must be passed for the paths
option. However, in reality, Node has been accepting a string for paths
, without complaint, for quite a while.
The upshot is that code that worked just fine with Node prior to 12.3.0 breaks with 12.3.0.
Metadata
Metadata
Assignees
Labels
No labels