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

Error says I must use 'import' when I'm clearly using 'import'!! #2304

Closed
johndeighan opened this issue Dec 2, 2019 · 2 comments
Closed

Comments

@johndeighan
Copy link

johndeighan commented Dec 2, 2019

 C:\Users\johnd\svelte\radio> ava test2.js


  × No tests found in test2.js

  1 uncaught exception

  Uncaught exception in test2.js

  C:\Users\johnd\svelte\radio\test2.js:2

   1: import test from 'ava';
   2: import {tname} from './testUtils.mjs';
   3:

  Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: 

What madness is this? I'm clearly using import!

FYI, my package.json file includes "type": "module", so I should not need to use the .mjs file extension, though I've tried that and I get the error message "Cannot apply enhancement-only precompilation, possible bad usage".

Here is my test2.js:

import test from 'ava';
import {tname} from './testUtils.mjs';

test("test 1", t => t.is(2, 2));
test("test 2", t => t.is('abc', 'abc'));
@novemberborn
Copy link
Member

You're a little ahead of the curve here. By default AVA 2 still compiles ESM syntax to CJS. You could disable that but AVA won't know to import() your test file so it still wouldn't work.

#2293 has more background and our plan for supporting ESM properly. I've now pinned this issue.

It'll take a bit of time for AVA (and I think the Node.js ecosystem at large) to adjust to the new ESM behavior in Node.js 13.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@johndeighan
Copy link
Author

johndeighan commented Dec 3, 2019 via email

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