Webpack: Bundle.js - Uncaught ReferenceError: process is not defined

后端 未结 5 1797
轻奢々
轻奢々 2020-12-31 00:06

Here\'s my webpack.config.js

\"use strict\";

module.exports = {
    entry: [\'./main.js\'],
    output: { path: __dirname, filename: \'bund         


        
5条回答
  •  自闭症患者
    2020-12-31 00:39

    Update October 2020:

    For webpack 5, you can reference process/browser from the appropriate plugins part of webpack.config.js

    // webpack needs to be explicitly required
    const webpack = require('webpack')
    
    module.exports = {
    
    /* ... rest of the config here ... */
    
      plugins: [
        // fix "process is not defined" error:
        // (do "npm install process" before running the build)
        new webpack.ProvidePlugin({
          process: 'process/browser',
        }),
      ]
    }
    

提交回复
热议问题