vue3安装web3启用时报错: webpack < 5 used to include polyfills for node.js core modules by default.

原因: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'
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值