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.48k stars 1.55k forks source link

使用electron-vue 进行web打包 #857

Open dingzesen opened 5 years ago

dingzesen commented 5 years ago

使用electron-vue运行npm run build:web,进行打包时,总是出现这个问题

ERROR in ./node_modules/conf/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/dingzesen/Desktop/elephant_sh/node_modules/conf'
 @ ./node_modules/conf/index.js 3:11-24
 @ ./node_modules/electron-store/index.js
 @ ./node_modules/vuex-electron/dist/persisted-state.js
 @ ./node_modules/vuex-electron/dist/index.js
 @ ./src/renderer/store/index.js
 @ ./src/renderer/main.js

ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/dingzesen/Desktop/elephant_sh/node_modules/electron'
 @ ./node_modules/electron/index.js 1:9-22
 @ ./node_modules/vuex-electron/dist/shared-mutations.js
 @ ./node_modules/vuex-electron/dist/index.js
 @ ./src/renderer/store/index.js
 @ ./src/renderer/main.js

ERROR in ./node_modules/graceful-fs/graceful-fs.js
Module not found: Error: Can't resolve 'fs' in '/Users/dingzesen/Desktop/elephant_sh/node_modules/graceful-fs'
 @ ./node_modules/graceful-fs/graceful-fs.js 1:9-22
 @ ./node_modules/write-file-atomic/index.js
 @ ./node_modules/conf/index.js
 @ ./node_modules/electron-store/index.js
 @ ./node_modules/vuex-electron/dist/persisted-state.js
 @ ./node_modules/vuex-electron/dist/index.js
 @ ./src/renderer/store/index.js
 @ ./src/renderer/main.js

ERROR in ./node_modules/make-dir/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/dingzesen/Desktop/elephant_sh/node_modules/make-dir'
 @ ./node_modules/make-dir/index.js 2:11-24
 @ ./node_modules/conf/index.js
 @ ./node_modules/electron-store/index.js
 @ ./node_modules/vuex-electron/dist/persisted-state.js
 @ ./node_modules/vuex-electron/dist/index.js
 @ ./src/renderer/store/index.js
 @ ./src/renderer/main.js

ERROR in ./node_modules/path-exists/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/dingzesen/Desktop/elephant_sh/node_modules/path-exists'
 @ ./node_modules/path-exists/index.js 2:11-24
 @ ./node_modules/locate-path/index.js
 @ ./node_modules/find-up/index.js
 @ ./node_modules/pkg-up/index.js
 @ ./node_modules/conf/index.js
 @ ./node_modules/electron-store/index.js
 @ ./node_modules/vuex-electron/dist/persisted-state.js
 @ ./node_modules/vuex-electron/dist/index.js
 @ ./src/renderer/store/index.js
 @ ./src/renderer/main.js
一直报错,应该是fs用不了,所以我就在webpack.web.config.js中添加了node:{fs:'empty'},之后不报错了,但是打包后打开网页出现这个问题:Uncaught TypeError: n.existsSync is not a function,这个问题应该是获取fs为空,所以找不到,那这个fs的问题怎么解决呢?
我是直接用官网的例子,然后运行npm install 后直接打包的,还是报错
有大佬能帮忙吗?
dingzesen commented 5 years ago

问题解决了 详细看https://github.com/SimulatedGREG/electron-vue/pull/751

hanshou101 commented 5 years ago

谢谢了昂,按照#751的方法,在build:web环境下排除【electron-vuex】之后,$ yarn run build:web 能够正常打包,且 index.html 文件能 正常运行不报错 了。

Thank you, follow the #751 method, after the exclusion of [electron-vuex] in the build: web environment, $ yarn run build: web can be packaged normally, and the index.html file can run normally without error.