0

I am using Quasar for my Electron development.

I need to use the path module and I'm requiring it at my electron-preload.js.

const path = require('path')

// Settings Directories
export const SRC_SETTINGS_DIR = path.resolve(__dirname, '../config')

console.log('Directory is: ' + SRC_SETTINGS_DIR)

However, I am getting this error message when running it:

module not found: path at preloadRequire

and

Unable to load preload script: C:\Users\me\Desktop\NodeJS\sample-tool\.quasar\electron\electron-preload.js

In my quasar.config.js, I have this:

      extendWebpack (cfg, { isServer, isClient }) {
        if (!cfg.externals) {
          cfg.externals = {}
        }
        Object.assign(cfg.externals, {
        })
      },
      chainWebpack (chain) {
        const nodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin')
        chain.plugin('node-polyfill').use(nodePolyfillWebpackPlugin)
      }

Any idea how to fix this?? How can I use the path module in electron-preload?

kzaiwo
  • 1,558
  • 1
  • 16
  • 45
  • possibly duplicate of https://stackoverflow.com/questions/58653223/why-does-preload-js-return-error-module-not-found – realjin Sep 15 '22 at 05:36

0 Answers0