原因:webpack5升级之后核心模块不在自动安装
方法一:
1.执行安装
npm install node-polyfill-webpack-plugin
2.复制代码到根目录下的vue.config.js
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
configureWebpack: {
plugins: [new NodePolyfillPlugin()],
},
3.最终文件内容
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
configureWebpack: {
plugins: [new NodePolyfillPlugin()],
},
transpileDependencies: true,
devServer: {
proxy: 'http://localhost:3000' // 配置访问的服务器地址
}
})
方法二:
1.根目录下新建webpack.config.js文件
const path = require('path');
module.exports = {
entry: path.join(__dirname, './src/main.js'),
output: {
path: path.join(__dirname, './dist'),
filename: 'index.js'
},
resolve: {
fallback: {
crypto: false,
http: false,
https: false
},
},
mode: 'development'
};

被折叠的 条评论
为什么被折叠?



