Does ES6 import/export need “.js” extension?

The extension is part of the filename. You have to put it in.

As proof of this, please try the following:

  • rename file to drawImage.test
  • edit index.js to contain './drawImage.test'

Reload, and you’ll see the extension js or test will be completely arbitrary, as long as you specify it in the export.

Obviously, after the test revert to the correct/better js extension.

Leave a Comment