Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'internal/bootstrap/loaders' #33656

Closed
dcastil opened this issue May 30, 2020 · 3 comments
Closed

Cannot find module 'internal/bootstrap/loaders' #33656

dcastil opened this issue May 30, 2020 · 3 comments

Comments

@dcastil
Copy link

dcastil commented May 30, 2020

  • Version: v12.17.0 (but same issue with v10.20.1, v10.13.0, v8.17.0 and v6.17.1)
  • Platform: Darwin dany 19.5.0 Darwin Kernel Version 19.5.0: Thu Apr 30 18:25:59 PDT 2020; root:xnu-6153.121.1~7/RELEASE_X86_64 x86_64
  • Subsystem: not sure

What steps will reproduce the bug?

Install NodeJS (I use n, but I also reinstalled with Node installer from website), create file test.js

require('internal/bootstrap/loaders')

and run

node test

How often does it reproduce? Is there a required condition?

I'm sure that it's not generally reproducible, but I can't figure out why this issue is occurring. I ran into this issue when I tried to use esm which internally uses require('internal/bootstrap/loaders').

What is the expected behavior?

Module can be loaded without throwing an error.

What do you see instead?

internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module 'internal/bootstrap/loaders'
Require stack:
- /Users/dany/code/theme-ui-vscode/test.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/dany/code/theme-ui-vscode/test.js:1:1)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/dany/code/theme-ui-vscode/test.js' ]
}

Additional information

I'm using a Mac with two users which are sharing node and npm (I'm using them for work / private), maybe that plays a role here? But the error happens on both users. I tried the proposed solutions of #9355 and #9377 but nothing worked for me unfortunately.

@dcastil
Copy link
Author

dcastil commented May 30, 2020

Actually a friend of mine just ran the command

echo "require('internal/bootstrap/loaders')" | node

on her machine and it threw the exact same error. 🤔

@richardlau
Copy link
Member

This is intentional. Internal modules are not meant to be require-able for user code. There is a command line flag to expose them to our own tests but we don't publicize that flag to minimize misuse.

If you're having issues with the esm module you should report that on their issues tracker.

@dcastil
Copy link
Author

dcastil commented May 30, 2020

Ah I just discovered that the require('internal/bootstrap/loaders') is in a try {} block. My bundler hoisted that require() call out of the try {} block which caused the issue.

Thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants