Unexpected import statement in CJS module.

2.x 导入一个第三方js库,一分钟解决的问题。
3.x,是真的头大,1、2天了,怎么搞都不行,报错也不太看懂。

[Preview]unhandledrejection: Unable to resolve bare specifier ‘__unresolved_1’ from http://localhost:7456/scripting/x/chunks/98/9895cc21fb89ce64aba113a9fea75cbebc21a617.js (SystemJS Error#8 https://git.io/JvFET#8)

[Programming] 无法加载模块 file:///Users/xxx/Documents/Projects/Projects/cli/MiniGame/assets/Script/libs/proto/protobuf-bundles.js :Error: Unexpected import statement in CJS module.

[Scene] Error: 无法从 pack:///chunks/98/9895cc21fb89ce64aba113a9fea75cbebc21a617.js 解析出模块 __unresolved_1。

2赞

如何解决呢

.js 文件后缀改成 .mjs 试试

package.json 中添加属性 "type": "module"

我也遇到了,大佬们,如何解决呢?