Import problem in ES6 Grammar

there is a utils folder in the root directory that contains index.js. Do I reference import utils from". / utils" in the entry file is tantamount to referencing the index.js file inside? if there are many other files, how is it referenced?

Apr.16,2022

first referencing a folder automatically references the following index.js, which is not a standard for ES6 import, but an implementation of nodejs's module system. So different module loaders can have different implementations for referencing a folder path, such as webpack,browserify follows the convention of nodejs.

it is also possible to refer to other files under the path, such as package.json,index.json...

clipboard.png

for more information on Node module loading algorithm, please see https://nodejs.org/api/module...

.

find utils.js first, and if not, find utils/index.js


the first floor talked about the import mechanism. If you have multiple files, you will import multiple times

.
Menu