nklayman / vue-cli-plugin-electron-builder

Easily Build Your Vue.js App For Desktop With Electron
https://nklayman.github.io/vue-cli-plugin-electron-builder/
MIT License
4.12k stars 280 forks source link

Electron Builder does not include dependencies prefixed with "node:" #2000

Open trek-eric opened 3 months ago

trek-eric commented 3 months ago

Describe the bug These dependencies were not found:

To install them, you can run: npm install --save node:http node:https node:os node:process node:stream node:util node:zlib ERROR Build failed with errors.

To Reproduce update a working vue app from 16 to 18 that includes a dependency prefixed with "node:" - Azure's appinsights is a great example

nvm use 16 vue create app cd app vue add electron-builder npm run electron:serve (works!) nvm use 18 npm update --save npm install --save applicationinsights add to background.js :

let appInsights = require("applicationinsights");
console.log(appInsights)

Expected behavior My understanding is prefixed modules with node:modulename should work fine - i am expecting the builder to build and include the dependencies as it did with node v.16

Environment (please complete the following information): eg: https://github.com/trek-eric/vue_app_18 - note the commits to see the working vs breaking change

trek-eric commented 3 months ago

i think i found my own solution - adding the offender to externals:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      // List native deps here if they don't work
      externals: ['applicationinsights'],
      // If you are using Yarn Workspaces, you may have multiple node_modules folders
      // List them all here so that VCP Electron Builder can find them
      nodeModulesPath: ['../../node_modules', './node_modules'],
    }
  }
})