Electron-builder causes SyntaxError: Cannot use import statement outside a module



  • I just started using electron-builder instead of electron-packager.

    I have added this to my package.json:

      "main": "./src-electron/main-process/electron-main.js",
      "build": {
        "productName": "someproductname",
        "win": {
           "target": ["portable"]
        },
       "portable": {
          "artifactName": "someproductnameport.exe"
        }
      },
    

    And in my quasar.conf.js:

          builder: {
            appId: 'com.electron.someproductname',
            nsis: {
              target: 'portable'
            }
          },
    

    It generates the bundle ok but when I try to run it, I get this error:
    import { app, BrowserWindow, nativeTheme } from 'electron'

    Error.JPG

    What am I doing wrong? Thanks!



  • Just a hunch, have you tried using require() instead of import for this case?


Log in to reply