standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

TypeError: Cannot read property 'options' of null #796

Open ben-page opened 5 years ago

ben-page commented 5 years ago

I'm trying to migrate to Node.js 12 and esm 3.2.22. I was using Node.js 10 and esm 3.0.8. I enable esm with node -r esm and use a .esmrc.js config file.

.esmrc.js

module.exports = {
    mainFields: ['module', 'main']
};

Stack Trace

TypeError: Cannot read property 'options' of null
    at Object.<anonymous> (C:\XXX\node_modules\esm\esm.js:1:248023)
    at Object.<anonymous> (C:\XXX\node_modules\esm\esm.js:1:227505)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at C:\XXX\node_modules\esm\esm.js:1:229608
    at C:\XXX\node_modules\esm\esm.js:1:229643
    at C:\XXX\node_modules\esm\esm.js:1:229856
    at wu (C:\XXX\node_modules\esm\esm.js:1:227529)
    at Pu (C:\XXX\node_modules\esm\esm.js:1:228943)
    at Rc (C:\XXX\node_modules\esm\esm.js:1:256728)
    at C:\XXX\node_modules\esm\esm.js:1:260727

This doesn't happen if I delete.esmrc.js or switch to .esmrc.json.

jdalton commented 5 years ago

Hi @ben-page!

Could you create a simple repro repo for me to investigate?

ben-page commented 5 years ago

https://github.com/ben-page/esm-bug

Here you go. BTW, I only confirmed this is a bug on esm 3.2.22 and Node.js v12.1.0.

Just run node i or yarn. Then run node -r esm index.js or node main.js.

jdalton commented 5 years ago

Thank you!