Uncaught SyntaxError: ambiguous indirect export: default

3k views Asked by At

This is my file structure. enter image description here

This is the location of dotenv folder. enter image description here

This is code for import and get API_KEY from ../../.env file.

import dotenv from '../../node_modules/dotenv/lib/main.js';
dotenv.config({ path: '.env' });
const apiKey = process.env.API_KEY;
console.log(apiKey);

This .js file location is ./app/js/app.js. When I run this code in web browser is trow this error message "Uncaught SyntaxError: ambiguous indirect export: default"

How can I solve this problem? Have I any other option to import my API_KEY from ../../.env file?

0

There are 0 answers