You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal/deps/cjs-module-lexer/lexer.js:882
throw new Error('Unexpected import statement in CJS module.');
^
Error: Unexpected import statement in CJS module.
at @:7:8
?[90m at throwIfImportStatement (internal/deps/cjs-module-lexer/lexer.js:882:13)?[39m
?[90m at parseSource (internal/deps/cjs-module-lexer/lexer.js:83:13)?[39m
?[90m at parseCJS (internal/deps/cjs-module-lexer/lexer.js:38:5)?[39m
?[90m at cjsPreparseModuleExports (internal/modules/esm/translators.js:193:34)?[39m
?[90m at Loader.commonjsStrategy (internal/modules/esm/translators.js:143:35)?[39m
?[90m at new ModuleJob (internal/modules/esm/module_job.js:38:41)?[39m
?[90m at Loader.getModuleJob (internal/modules/esm/loader.js:245:11)?[39m
?[90m at async ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:53:21)?[39m
at async Promise.all (index 0)
?[90m at async link (internal/modules/esm/module_job.js:58:9)?[39m {
loc: ?[33m109?[39m
}
The text was updated successfully, but these errors were encountered:
@bahuwang the problem here is that Node.js thinks that core.js is a CommonJS module not an ES module. To tell Node.js that it is an ES module you need to create a package.json with a "type": "module" field or you need to rename the file to use the mjs extension as core.mjs.
That the error message here didn't give the correction information is a bug though, I've posted a fix for a better message in #35426.
What steps will reproduce the bug?
@angular/core module file. https://github.com/bahuwang/issue/blob/master/core.js
demo.mjs file. https://github.com/bahuwang/issue/blob/master/demo.mjs
Just one line of code:
It is an ES modules, not CommonJS.
The text was updated successfully, but these errors were encountered: