Closed jclark-dot-org closed 5 years ago
Hi @jclark-dot-org!
Could you create a small repro repo that demonstrates the issue. It'll help me better diagnose the issue.
Thanks @jdalton. https://github.com/jclark-dot-org/esm-bug is a very simple repro.
Thanks @jclark-dot-org!
I created a PR against your simplified repro repo to fix your usage : )
Oops, that's embarrassing. Scrolling back through my buffer, I see that I should have caught that error when testing the repro.
However, those mistakes don't exist in my original project. So I accepted your pull request, made a minor adjustment to index.js to export the old way (for parity with the original project), and retested. It failed, but for a whole different reason (and I think a valid one - It wants my module to use ES6 constructor syntax). That's great... but it's not the error I'm seeing on my original project.
After doing some more comparing, I've found the difference. I committed the change and the repro repo fails again with the same error as my original bug report. I added "type": "module"
to my package.json, which I did in the original project based on https://nodejs.org/api/esm.html#esm_code_package_json_code_code_type_code_field. I guess I was conflating esm
with node 12's native ES6 support (which also requires command line args).
Removing "type": "module"
from my original project fixes the issue there as well, so I'll just avoid it for now and use esm
.
Thanks for all the help!
Related to #784.
(Brand new to ES6, and no wizard with node, so apologies in advance if I'm being dense).
node 12.0 "esm": "^3.2.22" "chai": "^4.2.0", "mocha": "^6.1.4"
I've got a brand new node project; I've added
mocha
andchai
, created anindex.js
and atest/test.js
with the beginnings of my new module. My tests passed. Then I decided to try to use ES6 syntax, so I changed the top of my test.js from this:to this:
Which gives an error, as node considers ES6 experimental:
So I google, and then I
npm install --save esm
, and I update my test command inpackage.json
:and try again. Still failing, very similar error, but with a new stack trace:
I'm not sure how to make the import any simpler, and I've seen other examples of folks using
esm
with chai. What am I missing?