Categories
JavaScript Answers

How to import from root with JavaScript?

Spread the love

To import from root with JavaScript, we use ~.

For instance, we write

import 'foo' from '~/components/foo.js';

to use ~ as the alias for the root folder when using import to import the foo module.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.