The following example script using vanilla javascript works well but not in Hugo:
I ran “hugo new site quickstart” and incorporated the above script. My package.json therefore has the line “type”: “module”.
I added a11y-dialog as a npm dependency yet it causes a weird error as if it cannot read the dependency in node_modules
import A11yDialog from ‘a11y-dialog’;
Uncaught TypeError: The specifier “a11y-dialog” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “…/” or “/”.
If I delete the above line and add the cookieconsent js files locally, I get the following:
import * as CookieConsent from ‘./cookieconsent-core-esm.js’;
Loading failed for the module with source “http://localhost:1313/js/cookieconsent-core-esm.js”.
Any ideas? I am completely baffled.
Regards, Alfred
Hugo v0.120.3
Node v20.9.0
Ubuntu (as a WSL on Windows)