This table associates different export statement forms with the expected export name and local names:
For importing, though...
- If you are importing a default export, you have to explicitly name the import. Default exports will not automatically have a local name after importing. Example:
import express from "express"
. The local name does not matter. Could as well beimport banana from "express"
. - If you are importing a named export, by default, the local name will be the same as the exported name. Example: If you have
export const x = 2
, then, you should import it asimport { x } from "module"
. You can also rename the import like this: `import { x as y } from "module".
From this StackOverflow entry