You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vue2迁移Vue3构建报错:TypeError: 无法读取undefined的styles属性

Vue2迁移Vue3构建报错:TypeError: Cannot read properties of undefined (reading 'styles')

正在使用迁移工具将项目从Vue2迁移至Vue3,执行构建时出现如下错误:

Syntax Error: TypeError: Cannot read properties of undefined (reading 'styles')

项目package.json依赖内容:

"dependencies": {
    "@game-streaming/game-streaming-vue-body-class-configure": "*",
    "@vue/compat": "^3.1.0",
    "vue": "^3.1.0",
    "vue-loader": "^16.0.0"
  },
  "devDependencies": {
    "@game-streaming/eslint-config-game-streaming": "*",
    "@types/node": "^17.0.17",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-typescript": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "@vue/compiler-sfc": "^3.5.12",
    "@vue/eslint-config-typescript": "^9.1.0",
    "eslint-plugin-vue": "^9.9.0",
    "ts-node": "^10.9.1",
    "typescript": "~4.5.5"
  },

vue.config.js配置内容:

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        // eslint-disable-next-line global-require,@typescript-eslint/no-var-requires
        '@': require('path').join(__dirname, 'src'),
      },
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          use: 'vue-loader',
        },
      ],
    },
  },
  chainWebpack: (config) => {
    config.resolve.alias.set('vue', '@vue/compat');
    config.module
      .rule('vue')
      .use('vue-loader')
      .tap((options) => ({
        ...options,
        compilerOptions: {
          compatConfig: {
            MODE: 3,
          },
        },
      }));
  },
};

已经尝试使用vue-loader v16版本,猜测问题可能和过时的vue-loader库有关,但不确定,寻求解决帮助。


内容的提问来源于stack exchange,提问作者Rae

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 18:40:01