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 'events' after 1.1.74 upgrade #46

Closed
anion155 opened this issue Nov 12, 2019 · 3 comments
Closed

Cannot find module 'events' after 1.1.74 upgrade #46

anion155 opened this issue Nov 12, 2019 · 3 comments

Comments

@anion155
Copy link

Imports of events module not working with pnpm after upgrade to v1.1.74 (does work in npm environment).

See example repo here.

@wessberg
Copy link
Owner

Hi there. I am not intimately familiar with pnpm but I did try your example repo out, and as you say, it's working fine with npm. I think I'm going to need more information to understand this issue, especially in what way rollup-plugin-ts may be related to it, as I'm not currently seeing it. Especially some error logs/stack traces would be useful.

@anion155
Copy link
Author

The main difference is that dependencies have access only to packages that listed in it's deps, peerDeps, etc list. So in provided repo's node_modules looks like this:

$ ls -l node_modules
итого 12
lrwxrwxrwx 1 anion anion   57 ноя 15 02:41 events -> .pnpm/registry.npmjs.org/events/3.0.0/node_modules/events
lrwxrwxrwx 1 anion anion   58 ноя 15 02:41 rollup -> .pnpm/registry.npmjs.org/rollup/1.27.0/node_modules/rollup
drwxrwxr-x 2 anion anion 4096 ноя 15 02:41 @types
lrwxrwxrwx 1 anion anion   65 ноя 15 02:41 typescript -> .pnpm/registry.npmjs.org/typescript/3.7.2/node_modules/typescript
drwxrwxr-x 2 anion anion 4096 ноя 15 02:41 @wessberg

And the output of rollup is:

$ rollup --config
./index.ts → ./result.js...
[!] (plugin Typescript) TS2307: Cannot find module 'events'.
index.ts (1:30)
1 import { EventEmitter } from 'events';
                               ~~~~~~~~

The problem could be, that resolve mechanism was changed in version 1.1.74.

@wessberg
Copy link
Owner

This has been solved. The problem was primarily that events also happens to be the name of a builtin module and the resolve algorithm would short-circuit if the given module name was identical to one of Node's builtin modules since it determined it to be unresolvable. The fix has been released with v1.1.80

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