0
Follow
5
View

When do we need to add file extension when importing JavaScript modules?

longnaxieye 注册会员
2023-01-26 05:38

It depends on your runtime and compilation environment, and also on whether you are using ES modules (the import syntax) or CommonJS modules (the require syntax). Find below an overview of the most common cases:

  • Webpack (used by Create React App and others tools) works with ES modules like so:
  • If you are using ES modules with Node.js or in the browser without any compilation step:
  • If you are using CommonJS modules with Node.js:

About the Author

Question Info

Publish Time
2023-01-26 05:38
Update Time
2023-01-26 05:38