Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

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
[email protected] /tmp/esm-issue
└── [email protected]

$ 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 [email protected]

$ 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants