- Run
npm install
- Make sure you're using Node 16+ (
nvm use 20
) - Run
node test.mjs
- 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
.