Axios Webpack:无法读取未定义的属性“创建”

时间:2020-07-14 08:30:32

标签: javascript reactjs webpack axios

我有一个与webpack 4集成的react项目,在集成webpack之后,当我'npm run dev'时出现此错误: 无法在eval(axios.js:5)上读取未定义的属性“ create”

我的axios.js文件:https://i.stack.imgur.com/8rKXo.png

我的webpack.config.js:

// webpack.config.js
const path = require( 'path' );
const HtmlWebPackPlugin = require( 'html-webpack-plugin' );
const LazyCompilePlugin = require('lazy-compile-webpack-plugin');
const webpack=require('webpack');
const dotenv = require('dotenv')
module.exports = {
    context: __dirname,
    entry: {
        main: './src/index.js',

      },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].main.js',
   },
   devServer: {
    historyApiFallback: true
    },
    module: {
        rules: [
            {
                test: /\.((c|sa|sc)ss)$/i,
                use: ['style-loader', 'css-loader','sass-loader'],
                
            },
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                use: ["babel-loader"],
            },
            {
                test: /\.(png|j?g|svg|gif)?$/,
                use: 'file-loader',
                include: path.resolve(__dirname, 'src')
             }
        ]
    },

    resolve: {
        modules: ['.','node_modules']
    },
    plugins: [
        new HtmlWebPackPlugin({
           template: path.resolve( __dirname, 'public/index.html' ),
           filename: 'index.html'
        }),

         new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
          })
       
     ],
    
    
};

任何帮助文章

0 个答案:

没有答案