我正在使用Vue 3,并根据文档添加了highchartsjs。我得到了这个错误:
✘ [ERROR] Could not resolve "highcharts"
node_modules/highcharts-vue/dist/highcharts-vue.min.js:1:90:
1 │ ...?module.exports=e(require("highcharts"),require("vue")):"functio...
╵ ~~~~~~~~~~~~
You can mark the path "highcharts" as external to exclude it from the bundle,
which will remove this error. You can also surround this "require" call with a
try/catch block to handle this failure at run-time instead of bundle-time.
我尝试按照建议将其从包中排除,但没有效果:
vite.config.js
export default defineConfig({
...
build: {
rollupOptions: {
external: ['highcharts'],
}
},
})
2条答案
按热度按时间b4wnujal1#
这是可行的:
rkue9o1l2#
通过
optimizeDeps.exclude
排除highcharts
可以清除错误,但这会使您在项目中使用highcharts
的最终目标落空。您会注意到,在使用该配置后,您的项目仍然无法导入highcharts
。该错误表明您的项目缺少该依赖项。解决方案是安装
highcharts
:demo