当前位置: 移动技术网 > IT编程>开发语言>JavaScript > electron-vue项目启动&&解决 process is not defined以及带来的Cannot find module ‘axios‘等问题

electron-vue项目启动&&解决 process is not defined以及带来的Cannot find module ‘axios‘等问题

2020年09月29日  | 移动技术网IT编程  | 我要评论
electron-vue项目启动通过vue-cli构建指令:vue init simulatedgreg/electron-vue my-project创建后进行包安装yarn或者npm installElectron-vue ReferenceError: process is not defined修改你项目文件下.electron-vue里面的webpack.renderer.config.js和webpack.web.config.js./.electron-vue

electron-vue项目启动

  1. 通过vue-cli构建
    指令:
vue init  simulatedgreg/electron-vue my-project
  1. 创建后进行包安装
yarn
或者
npm install

Electron-vue ReferenceError: process is not defined

修改你项目文件下.electron-vue里面的webpack.renderer.config.js和webpack.web.config.js
./.electron-vue文件

两个文件修改的内容都是一样的

new HtmlWebpackPlugin({
      filename: '',
      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
    }),

最终webpack.web.config.js修改完成后内容如下:
webpack.web.config.js添加的内容

而webpack.renderer.config.js修改完成后的内容如下:
webpack.renderer.config.js添加的内容

修改后可能会出现另一个问题:

Cannot find module 'axios’等问题


解决方案:
在webpack.render.config.js中 找到

let whiteListedModules = ['vue']

将其修改为:

let whiteListedModules = ['vue','axios','vue-electron', 'vue-router', 'vuex', 'vuex-electron','element-ui']

官网解释:

本文地址:https://blog.csdn.net/qq_44831027/article/details/108874837

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网