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

Incorrect "main" entry in package.json is used #770

Closed
dorian-marchal opened this issue Mar 28, 2019 · 3 comments
Closed

Incorrect "main" entry in package.json is used #770

dorian-marchal opened this issue Mar 28, 2019 · 3 comments

Comments

@dorian-marchal
Copy link

dorian-marchal commented Mar 28, 2019

When a package with a faulty main entry is imported, esm throws with:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

Without using esm, index.js is used as the entry point.

Note that this is a regression in 3.2.21. 3.2.20 works as expected.

Here is a small repro using find-parent-dir (a package with a bad main entry): https://github.com/dorian-marchal/esm-issue

$ git clone https://github.com/dorian-marchal/esm-issue
Cloning into 'esm-issue'...

$ cd esm-issue/

$ node -v
v10.14.1

$ npm ls esm
esm-issue@1.0.0 /tmp/esm-issue
└── esm@3.2.21

$ node without-esm.js
OK

$ node with-esm.js
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at dirname (path.js:1268:5)
    at Object.<anonymous> (/tmp/esm-issue/with-esm.js:2:1)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)

$ npm install esm@3.2.20

$ node with-esm.js
OK
@jdalton
Copy link
Member

jdalton commented Mar 28, 2019

Thank you @dorian-marchal!

This is hitting because esm has early adopted a change coming in Node (soon). This is good to know so I can pass this along to them.

Update:

Turns out it was typos on my end.

Update:

esm v3.2.21 is released 🎉

@dorian-marchal
Copy link
Author

Thank you! 💪

@dorian-marchal

This comment has been minimized.

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

No branches or pull requests

2 participants