How to solve referenceerror module is not defined

2.9k Views Asked by At

I am trying to import asva-js-password-package client side as below

<script src="https://unpkg.com/@marcusfernstrom/[email protected]/index.js"></script>

But I am getting a referenceerror module is not defined in the browser console. How can I solve this?

1

There are 1 best solutions below

0
On

You can't with this file alone.

The module have not been written in es6 module style, but in CommonJS. If you want to import this file as is, it wont works unless you import a library that support this syntax (like requireJS).

Another solution can be to compile this file with a JS transpiler like browserify that will produce a file browser compatible.