-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
SyntaxError: Cannot use import statement outside a module #5125
Comments
egg 目前不支持 esm,请使用 cjs 模式 |
这个是巨坑,依赖第三方模块如果是esm,彻底凉!!! |
@zldoc88 这是基础常说,跟 egg 无关。egg 目前只支持 cjs。 |
我现在用的场景是 egg - ts, 依赖模块a, a里面依赖b模块,我把a的源码本地重打出个cjs,但b模块是esm模块,但引a进去后彻底崩溃。。。。 |
ts 并不解决 esm 和 cjs 的兼容性问题的,这是两码事。 |
@fengmk2 考不考虑把 egg-core 里面的 FileLoader 从 require 改为 import ? 对应用侧应该 break 不了,只是框架侧有自定义 loader lifecycle 的,如果有覆盖了 loader 内置的函数,需要改为 async + await,改动量很小。 |
egg-core 会替换成 artusjs/core 么 |
Your detail info about the Bug:
出现这样一个报错,[egg-scripts] SyntaxError: Cannot use import statement outside a module
查了很久,网上有人推荐在package.json中修改type:module 来解决,但是尝试了之后发现会导致egg内部其他的报错。暂时未找到其他的解决方法,所以问问有什么解决方案
Reproduction Repo
null
Node Version
16.14.1
Eggjs Version
3.12.0
Plugin Name and its version
null
Platform and its version
win11
The text was updated successfully, but these errors were encountered: