Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using a import statement inside a module #600

Open
joaocstro opened this issue Oct 8, 2022 · 1 comment
Open

Error when using a import statement inside a module #600

joaocstro opened this issue Oct 8, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@joaocstro
Copy link

When i try to use a import statement inside a module, i get the following error:

evalmachine.<anonymous>:1
import { activateElement, deactivateElement } from './utils/utils.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at new Script (node:vm:100:7)
    at createScript (node:vm:265:10)
    at Object.runInContext (node:vm:296:10)
    at Window.eval /node_modules/happy-dom/lib/window/Window.js:366:33)
    at Function.loadExternalScript (/node_modules/happy-dom/lib/nodes/html-script-element/ScriptUtility.js:69:51)
    at HTMLScriptElement._connectToNode (/node_modules/happy-dom/lib/nodes/html-script-element/HTMLScriptElement.js:177:41)
    at HTMLElement._connectToNode (/node_modules/happy-dom/lib/nodes/node/Node.js:435:23)
    at HTMLElement._connectToNode (/node_modules/happy-dom/lib/nodes/node/Node.js:435:23)
    at HTMLDocument.appendChild (/node_modules/happy-dom/lib/nodes/node/Node.js:249:14)
    at HTMLDocument.appendChild (/node_modules/happy-dom/lib/nodes/document/Document.js:486:22)

The script tag is defined as following: <script src="/scripts/global.js" type="module"></script>

I'm using Happy Dom version 7.4.0, but the problem also occurred in 6.0.4. My Node.js version is 16.17.0.

@capricorn86
Copy link
Owner

Relates to #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants