reesscot / amplify-js-v6-node-esm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Steps to reproduce Node ESM error

  1. Run npm install
  2. Make sure you're using Node 16+ (nvm use 20)
  3. Run node test.mjs
  4. See the following error:
file:///Users/[USERNAME]/amplify-js-v6-node-esm/test.mjs:1
import { signIn } from 'aws-amplify/auth';
         ^^^^^^
SyntaxError: Named export 'signIn' not found. The requested module 'aws-amplify/auth' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'aws-amplify/auth';
const { signIn } = pkg;

This would be a regression of the Node ESM module support Amplify JS and UI libraries currently have. Also see: aws-amplify/amplify-ui#3155

The simplest way to fix this issue would be to make sure Node understands which files are ESM compatible by changing their file extension to mjs.

About

License:Apache License 2.0


Languages

Language:JavaScript 100.0%