昨天的代碼好好的沒動,第二天早上一來項目就運行不起來了,報了這個ReferenceError: process is not defined,心想這也沒改啥啊 誰還能動我代碼不成?后來才知道那天更新了node版本12以上,之前是10.1.17,才導致的這個問題。所以直接把node退回到10版本的就行。https://nodejs.org/dist/latest-v10.x/ 這個地址是node之前發(fā)布過的版本。
當然,如果不想回退node版本的話就按照下面的步驟改下代碼
首先修改.electron-vue下面的這兩個文件

QQ圖片20191128173310.png
首先修改renderer.config.js!
(圖片為修改后的代碼)直接復制下面代碼替換就行了

QQ圖片20191128173304.png
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, '../src/index.ejs'),
minify: {
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true
},
templateParameters(compilation, assets, options) {
return {
compilation: compilation,
webpack: compilation.getStats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
},
process,
};
},
nodeModules: process.env.NODE_ENV !== 'production'
? path.resolve(__dirname, '../node_modules')
: false
}),
然后修改web.config.js的new new HtmlWebpackPlugin這一塊 將下面代碼復制替換
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
}),
然后重啟項目運行,就可以了,也算是踩了一個大坑,尤其度娘的時候,搜到的答案都不明不白的,大多都是不知道從哪復制粘貼的,有的只改一個,有的兩段代碼改的都一樣,改完以后根本不能用,耽誤了不少時間。
字都是一個一個敲出來的,如果幫到你了給點個贊吧!