I am new to JavaScript and have been struggling with import recently. One thing that I can’t cover my head with.
In older node modules (mainly those that came to see the light before ES6) that can be installed using npm, such as express , the default export is usually not defined.
My IDE (WebStorm) marks the following line: the default export export is not declared in the notification of the imported module.
import express from 'express';
You can get around this message by trying to import the entire module as an alias using
import * as express from 'express';
By implicitly telling my IDE to simply import everything and call it express , however, this leads to the fact that express is not a functional error when trying to create an application instance on the next line.
const app = express();
In particular, the original import works (without an alias).
What exactly is imported using the import statement without an alias when the default export is not set? I would think that this is the whole module, but it is not.
javascript import ecmascript-6
David packer
source share