amis build报错

fnvucqvd  于 4个月前  发布在  其他
关注(0)|答案(4)|浏览(43)

npm run build报错:

`
[!] RollupError: Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.

Original error: Cannot use import statement outside a module
`

尝试按提示把rollup.config.js文件扩展名改成mjs,又报另一个错:

===rollup build=== [!] TypeError: Module "file:///Users/Work/Product/code/amis/packages/amis/package.json" needs an import assertion of type "json" at new NodeError (node:internal/errors:372:5) at validateAssertions (node:internal/modules/esm/assert:82:15) at defaultLoad (node:internal/modules/esm/load:24:3) at ESMLoader.load (node:internal/modules/esm/loader:407:26) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:22) at new ModuleJob (node:internal/modules/esm/module_job:66:26) at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:345:17) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:304:34) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:82:21) at async Promise.all (index 6)

Node版本:16
NPM版本:8
npm run dev没问题

igsr9ssn

igsr9ssn1#

@boxui 麻烦说一下背景信息:
1、使用的是哪个项目?amis 还是 amis-editor-demo,还是其他?
2、是否拉取了最新代码?
3、有无调整构建配置?

mi7gmzs6

mi7gmzs62#

@boxui 麻烦说一下背景信息: 1、使用的是哪个项目?amis 还是 amis-editor-demo,还是其他? 2、是否拉取了最新代码? 3、有无调整构建配置?

1、使用amis项目
2、拉了master最新代码
3、无调整构建配置

npm start项目能正常运行,npm run build才报错

emeijp43

emeijp433#

没有复现你说的问题,删除所有node_modules和lock文件后重装下依赖试下。

aoyhnmkz

aoyhnmkz4#

请问这个问题解决了吗,我这边也是start可以,run build不行,删了node_modules重试还是不行
windows10
node 16.17.0
npm 8.15.0
amis是最新的6.0.0

相关问题