Javascript language specification is standardized, by ECMAScript specification.
the ES in ES6 is short for ECMAScript
In ES6, which is the current standard for javascript, using import is the standard.
However, in nodeJS, we often see require to use modules. This is because before ES6 standard, nodeJS introduced CommonJS as its standard, and this used require to use modules.
So currently, it is recommended to use import.
Some of its advantages are
import is determined at compile time, asynchronously. so enables:Promise to resolve module importsBut we still need to konw require
as it
I hear it is pain to create a js module that can handle both import and require.