You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module stat cache keeps broken results in cache #26926
Platform: Linux bb-laptop 5.0.4-arch1-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Sat Mar 23 21:00:33 UTC 2019 x86_64 GNU/Linux
Subsystem: module
Actual behavior: requireing a non-existing file throws a MODULE_NOT_FOUND error, creating the file afterwards and trying to require again still throws.
Expected behavior:
The second call to require should resolve to the actual file content.
Try the following three lines in a REPL (Node v11.10.1 vs Node v11.11.0):
It seems like the bug was introduced with this commit: d94f4c23fe - I built Node.js with this commit and with its parent commit and was able to observe the above mentioned behavior.
// 1.jstry{require('anything-needs-lookup');}catch(e){}require('./any-related-js');require('fs').mkdirSync('./node_modules');require('fs').writeFileSync('./node_modules/non-existent.json','1');// module._compile('', ''); // we use this hack to workaround this issueconsole.log(require('non-existent.json'))
@lwr your issue is unrelated to the issue originally mentioned.
I am not certain if your example ever used to work. I tried almost all Node.js versions down to v6.17.1 and all threw the Cannot find module error. It is not really intended to create not found node_modules on the fly during the loading phase and to reload them in the same phase.
Activity
addaleax commentedon Mar 26, 2019
/cc @BridgeAR
fix(webpack): use async-node target to circumvent Node 11.11.0 bug
fix(webpack): use async-node target to circumvent Node 11.11.0 bug
fix(webpack): use async-node target to circumvent Node 11.11.0 bug
thetutlage commentedon Apr 3, 2019
Yes, facing the exact same issue. Discovered while I was writing some tests
module: fix repl require calling the same file again
module: fix repl require calling the same file again
module: fix repl require calling the same file again
module: fix repl require calling the same file again
lwr commentedon Jan 20, 2020
not works for paths cache (node_modules)
test case
1.jsActual behavior:
test in node 13.6.0
Expected behavior:
-- (uncomment the line that workaround this problem) --
output 1
BridgeAR commentedon Jan 20, 2020
@lwr your issue is unrelated to the issue originally mentioned.
I am not certain if your example ever used to work. I tried almost all Node.js versions down to v6.17.1 and all threw the
Cannot find moduleerror. It is not really intended to create not found node_modules on the fly during the loading phase and to reload them in the same phase.lwr commentedon Jan 22, 2020
@BridgeAR I am sorry for something wrong in the test case
one line added to the test
try { require('anything-needs-lookup'); } catch (e) {} + require('./any-related-js');and the test command changed to
the test is passed in 10.17.0 / failed in 13.6.0
make 'debug' as dependencies
make debug as dependencies