0

I'm trying to import interact.js with an importmap, but I get the error:

Uncaught SyntaxError: Unexpected identifier 'interactjs'.

My importmap:

<script type="importmap">
    {
        "imports": {
            "interactjs": "https://cdn.interactjs.io/v1.9.20/interactjs/index.js"
        }
    }
</script>

My JavaScript code:

<script type="module">
    import interact from interactjs;

    interact('.item').draggable({
        onmove(event) {
            console.log(event.pageX, event.pageY)
        },
    })
</script>

A normal script src include works without issue.

<script src="https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js"></script>

Any ideas?

0

1 Answer 1

0

James provided the correct solution to the issue in a comment:

The examples here have quotes around the from target. eg import thing from 'here'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.