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

Node >= v12.16.0 Cannot install a module without an index.js at root after require() has been called once #28

Open
deepal opened this issue Mar 14, 2020 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@deepal
Copy link
Owner

deepal commented Mar 14, 2020

Steps to reproduce:

  • Install chance first
  • Install underscore second

underscore does not have an index.js at the module root. Instead, the entry point is configured via main attribute in package.json

> require('chance')
Fetching and installing module 'chance' from npm...
Done!
[Function: Chance] { Chance: [Circular] }
> require('underscore')
Fetching and installing module 'underscore' from npm...
Done!
Uncaught:
Error: Cannot find module '/Users/deepal/.baapan/workspace_90531_1584193257750/node_modules/underscore'
Require stack:
- <repl>
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at Module._module.Module.require (/Users/deepal/Projects/baapan/src/baapan.js:131:34)
    at require (internal/modules/cjs/helpers.js:77:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '<repl>' ]
}
> 

This happens if the require() has been called once to install a module dynamically. Installation of the second module is successful, but it cannot be required and throws MODULE_NOT_FOUND error.

This issue is specific to Node v12.16.0 and above.

This issue is due to nodejs/node#29492

@deepal deepal added the bug Something isn't working label Mar 14, 2020
@deepal deepal added this to the 3.5.0 milestone Mar 14, 2020
@deepal deepal changed the title Cannot install a module without an index.js at root after require() has been called once Node v12.x.x Cannot install a module without an index.js at root after require() has been called once Mar 14, 2020
@deepal deepal changed the title Node v12.x.x Cannot install a module without an index.js at root after require() has been called once Node >v12.x.x Cannot install a module without an index.js at root after require() has been called once Mar 14, 2020
@deepal deepal changed the title Node >v12.x.x Cannot install a module without an index.js at root after require() has been called once Node >= v12.16.0 Cannot install a module without an index.js at root after require() has been called once Mar 15, 2020
@deepal deepal added critical bug bug Something isn't working and removed bug Something isn't working labels Mar 15, 2020
@deepal
Copy link
Owner Author

deepal commented Mar 15, 2020

This issue is being investigated. Until then a minor workaround is added in #31 and a compatibility warning is displayed as follows.

Screenshot 2020-03-15 at 21 12 53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant