Can I have any way to import module about aws-export.js?

Viewed 436

Now I'm trying to import aws-exports.js which amplify-js automatically generates in node es6 type code.

my code like this. ex:something.mjs

#!/usr/bin/env node

import awsmobile from '../src/aws-exports.js';

something ....

and I try to execute under bellow

# ./something.mjs

export default awsmobile;
^^^^^^

SyntaxError: Unexpected token 'export'

then, the above error will be output.

I wonder, the aws-exports.js generated by amplify-js is in es6 format, but the extension is js. Is this the only way to execute it by writing "module" as the "type" field of package.json?

2 Answers

Changing file to .ts worked for me.

deleting the aws-exports.js file and then running "amplify configure project" worked for me

Related