问题
error in ./node_modules/cesium/Source/ThirdParty/zip.js
解决
安装@open-wc\webpack-import-meta-loader
并在vue.config.js中配置
configureWebpack: {
name: name,
module: {
rules: [
{
test: /.js$/,
use: {
loader: '@open-wc/webpack-import-meta-loader',
},
},
],
},
}
后遗症
以上配置后运行正常但是打包报错TypeError: Cannot read property 'length' of undefined
解决
修改node_modules\@open-wc\webpack-import-meta-loader\webpack-import-meta-loader.js
中代码
const relativePath = this.context.substring(
// this.context.indexOf(this.rootContext) + this.rootContext.length + 1, //注释掉此行代码
this.resource.lastIndexOf(path.sep) + 1,
);

在Vue项目中使用Cesium库时遇到了错误`error in ./node_modules/cesium/Source/ThirdParty/zip.js`。为了解决这个问题,需要安装`@open-wc/webpack-import-meta-loader`并在`vue.config.js`中配置相应的模块规则。然而,配置后虽然运行正常,但在打包过程中却出现`TypeError: Cannot read property 'length' of undefined`的错误。这个问题可以通过修改`webpack-import-meta-loader.js`文件中的特定代码来解决,注释掉引起错误的行。
436





