// "default export" cannot be destructured
import { name } from './default_export.js'; // ⛔ error
// ^^^^
// ⛔ SyntaxError:
// The requested module './default_export.js'
// does not provide an export named 'name'
export default is imported differently,
there are no curly braces around the imported value.
imported namecan be different from the default export name.
replit:
// 📁 module.js
export default A; // ⭐️ export default
// ⭐️ import without `{}` ( not `{B}`❗️)
import B from "./module.js"; // ⭐️ use nay name of your choice
import defaultExport, {otherExport, ...} from "./module.js";
another example:
// ⭐️ import "named export"
import { pi } from './named_export.js';
// ⭐️ import "default export"
import who from './default_export.js'; // OK
// ⭐️ "default export" cannot be destructured
//
// import { name } from './default_export.js'; // ⛔ error
// ^^^^
// ⛔ SyntaxError:
// The requested module './default_export.js'
// does not provide an export named 'name'
📁 named_export.js
const pi = Math.PI;
export { pi }; // ⭐️ named export