Gar*_*yan 12 javascript rollup package babeljs
我想安装rollup-plugin-visualizer,但需要更新汇总。
更新汇总从1.8.0到3.1.0
出现错误
[!] 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.
Run Code Online (Sandbox Code Playgroud)
删除node-modules文件夹和package-lock.json并再次安装npm i
出现错误
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: @bet-core/ui@2.4.0
npm ERR! Found: rollup@3.1.0
npm ERR! node_modules/rollup
npm ERR! dev rollup@"^3.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rollup@">=0.60.0 <3" from rollup-plugin-babel@4.4.0
npm ERR! node_modules/rollup-plugin-babel
npm ERR! dev rollup-plugin-babel@"^4.3.2" from the root project
Run Code Online (Sandbox Code Playgroud)
rollup-plugin-babelnpm 页面说!!!
rollup-plugin-babel然后安装@rollup/plugin-babel.
现在我收到此错误[!] 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
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我在哪里寻找这个错误的解决方案吗?
Gar*_*yan 11
我已经找到解决方案了。首先将格式从 更改'esm'为'cjs'inrollup.config.js
export default {
...
output: [
{
format: 'cjs',
...
},
]
};
Run Code Online (Sandbox Code Playgroud)
然后rollup.config.js改为rollup.config.mjs
你好,我在运行“npm run rollup”时遇到同样的问题
RollupError:Node 尝试将您的配置文件加载为 CommonJS,即使它可能是 ES 模块。要解决此问题,请将配置的扩展名更改为“.mjs”,在 package.json 文件中设置“type”:“module”或传递“--bundleConfigAsCjs”标志。
我发现了什么:
| 归档时间: |
|
| 查看次数: |
18155 次 |
| 最近记录: |