Vue中启动提示polyfill缺少-webpack v5版本导致

安装

npm i node-polyfill-webpack-plugin

因为我们的项目使用webpack v5,其中polyfill Node核心模块被删除。所以,我们安装它是为了在项目中访问这些模块

vue.config.js文件

const { defineConfig } = require("@vue/cli-service");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    plugins: [new NodePolyfillPlugin()],
    optimization: {
      splitChunks: {
        chunks: "all",
      },
    },
  },
});

你可能感兴趣的:(Vue,ERROR,vue.js,webpack,前端)