Failed to resolve module specifier

Sami C.
1 min readMay 9, 2020

Today I got stuck when trying to load a module:

import(`folder/myModule.js`).then((response) => {});Error: Failed to resolve module specifier

Until I stumbled upon a stackoverflow answer providing me with some insights on how to dynamically load a module in JavaScript.

A module must be either a full URL (including a protocol), an absolute path (starting with /), or a relative path (starting with ./ or ../).

I simply added a slash in front of my URL and it worked!

import(`/folder/myModule.js`).then((response) => {});

Enjoy!

--

--