Привет! У меня есть такой модуль vuex, к которому я подключил electron-store, но мне…
- User
Привет! У меня есть такой модуль vuex, к которому я подключил electron-store, но мне выдаются следующие ошибки import Store from 'electron-store';
const persistentStore = new Store();
export const playerModule = { namespaced: true, state: () => ({ nickname: persistentStore.get('nickname') || '', }), getters: { getNickname: (state) => state.nickname, }, mutations: { setNickname(state, nickname) { state.nickname = nickname; persistentStore.set('nickname', nickname) }, }, actions: { updateNickname({ commit }, nickname) { commit('setNickname', nickname); }, } }
Syntax Error: Reading from "node:fs" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs.
error in node:os
Syntax Error: Reading from "node:os" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs.
error in node:path
Syntax Error: Reading from "node:path" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs.
error in node:process
Syntax Error: Reading from "node:process" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs.
error in node:util
Syntax Error: Reading from "node:util" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs.
ERROR in ./node_modules/electron/index.js 1:11-24 Module not found: Error: Can't resolve 'fs' in 'D:\dev\vue-electron-apps\overboard-app\node_modules\electron' @ ./node_modules/electron-store/index.js 3:0-32 9:4-12 38:22-51 @ ./src/store/playerModule.js 1:0-35 2:28-33 @ ./src/store/index.js 2:0-52 5:12-24 @ ./src/main.js 7:0-28 12:8-13
ERROR in ./node_modules/electron/index.js 2:13-28 Module not found: Error: Can't resolve 'path' in 'D:\dev\vue-electron-apps\overboard-app\node_modules\electron'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }' - install 'path-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "path": false } @ ./node_modules/electron-store/index.js 3:0-32 9:4-12 38:22-51 @ ./src/store/playerModule.js 1:0-35 2:28-33 @ ./src/store/index.js 2:0-52 5:12-24 @ ./src/main.js 7:0-28 12:8-13
ERROR in node:assert Module build failed: UnhandledSchemeError: Reading from "node:assert" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs. at D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\NormalModule.js:984:10 at Hook.eval [as callAsync] (eval at create (D:\dev\vue-electron-apps\overboard-app\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1) at Object.processResource (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\NormalModule.js:980:8) at processResource (D:\dev\vue-electron-apps\overboard-app\node_modules\loader-runner\lib\LoaderRunner.js:220:11) at iteratePitchingLoaders (D:\dev\vue-electron-apps\overboard-app\node_modules\loader-runner\lib\LoaderRunner.js:171:10) at runLoaders (D:\dev\vue-electron-apps\overboard-app\node_modules\loader-runner\lib\LoaderRunner.js:398:2) at NormalModule._doBuild (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\NormalModule.js:965:3) at NormalModule.build (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\NormalModule.js:1155:15) at D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\Compilation.js:1422:12 at NormalModule.needBuild (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\NormalModule.js:1477:32) at Compilation._buildModule (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\Compilation.js:1403:10) at D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\util\AsyncQueue.js:340:10 at Hook.eval [as callAsync] (eval at create (D:\dev\vue-electron-apps\overboard-app\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1) at AsyncQueue._startProcessing (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\util\AsyncQueue.js:330:26) at AsyncQueue._ensureProcessing (D:\dev\vue-electron-apps\overboard-app\node_modules\webpack\lib\util\AsyncQueue.js:317:12) at process.processImmediate (node:internal/timers:471:21) @ ./node_modules/conf/dist/source/index.js 21:0-33 126:6-22 @ ./node_modules/electron-store/index.js 4:0-24 30:43-47 @ ./src/store/playerModule.js 1:0-35 2:28-33 @ ./src/store/index.js 2:0-52 5:12-24 @ ./src/main.js 7:0-28 12:8-13
- Assistant
Проблемы, с которыми вы столкнулись, связаны с тем, что Webpack 5 больше не включает полифилы для модулей Node.js. Это означает, что при использовании
electron-storeи других модулей, зависимых от Node.js, необходимо настраивать Webpack для работы с ними.Вот несколько шагов, которые помогут вам решить проблему:
1. Установите необходимые полифилы
Вам нужно установить полифилы для модулей Node.js, которые используются в . Это можно сделать следующим образом:
- User
Что такое полифилы?
- Assistant
Полифилы (или "polyfills") — это фрагменты кода (обычно написанные на JavaScript), которые обеспечивают поддержку современных функций языка или API, которые отсутствуют в некоторых старых браузерах или средах. Они позволяют разработчикам использовать новые возможности языка, не беспокоясь о том, что их код не будет работать в устаревших системах.