Electron-vue: 刚刚下载完依赖,运行时报错

Created on 8 Apr 2020  ·  6Comments  ·  Source: SimulatedGREG/electron-vue

ReferenceError: process is not defined

  • index.ejs:11 eval
    [.]/[html-webpack-plugin]/lib/loader.js!./src/index.ejs:11:2

  • index.ejs:16 module.exports
    [.]/[html-webpack-plugin]/lib/loader.js!./src/index.ejs:16:3

  • index.js:284
    [zhuyuzaixian]/[html-webpack-plugin]/index.js:284:18

  • runMicrotasks

  • task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

Most helpful comment

我也遇到了这个问题,可能是一个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修复。

All 6 comments

我也遇到了这个问题,可能是一个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修复。

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

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

Maybe I can submit a pr

Patch has been submitted

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kinoli picture kinoli  ·  3Comments

alexiej picture alexiej  ·  3Comments

Quadriphobs1 picture Quadriphobs1  ·  3Comments

blackw212 picture blackw212  ·  3Comments

rodrigomata picture rodrigomata  ·  3Comments