SimulatedGREG / electron-vue

An Electron & Vue.js quick start boilerplate with vue-cli scaffolding, common Vue plugins, electron-packager/electron-builder, unit/e2e testing, vue-devtools, and webpack.
https://simulatedgreg.gitbooks.io/electron-vue/content/
MIT License
15.47k stars 1.54k forks source link

刚刚下载完依赖,运行时报错 #1003

Closed tjl-with-code closed 3 years ago

tjl-with-code commented 4 years ago

ReferenceError: process is not defined

jack9603301 commented 4 years ago

我也遇到了这个问题,可能是一个bug,但可以解决 修改.electron-vue/webpack.web.config.js.electron-vue/webpack.renderer.config.js,在文件里搜索index.html字符串。 可以见到如下内容:

  plugins: [
    new VueLoaderPlugin(),
    new MiniCssExtractPlugin({filename: 'styles.css'}),
    new HtmlWebpackPlugin({
      filename: 'index.html',                                                                                                                                                                                                                 
      template: path.resolve(__dirname, '../src/index.ejs'),
      minify: {
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        removeComments: true
      },
      nodeModules: false
    }),

修改为:

  plugins: [
    new VueLoaderPlugin(),
    new MiniCssExtractPlugin({filename: 'styles.css'}),
    new HtmlWebpackPlugin({
      filename: 'index.html',                                                                                                                                                                                                                 
      template: path.resolve(__dirname, '../src/index.ejs'),
      templateParameters(compilation, assets, options) {
        return {
          compilation: compilation,
          webpack: compilation.getStats().toJson(),
          webpackConfig: compilation.options,
          htmlWebpackPlugin: {
            files: assets,
            options: options
          },
          process,
        };
      },
      minify: {
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        removeComments: true
      },
      nodeModules: false
    }),

我也是从百度搜索知道解决方案,可能是个bug。如果有兴趣,你可以使用英文重新提交一个issus,或者提交pr修复。

liper commented 4 years ago

这个脚手架的包版本比较低,把node版本降到10.X也可以解决这个问题

exislow commented 3 years ago

@jack9603301 this fixes the problem, thanks. Can somebody fix this in this repo?

jack9603301 commented 3 years ago

Maybe I can submit a pr

jack9603301 commented 3 years ago

Patch has been submitted

jack9603301 commented 3 years ago

It seems that my patch and #1020 are duplicated, I will close my pr