vue-cli-plugin-electron-builder icon indicating copy to clipboard operation
vue-cli-plugin-electron-builder copied to clipboard

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

Open trek-eric opened this issue 1 year ago • 1 comments

Describe the bug These dependencies were not found:

  • node:http in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/nodeHttpClient.js
  • node:https in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/nodeHttpClient.js
  • node:os in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/util/userAgentPlatform.js, ./node_modules/@azure/logger/dist/commonjs/log.js
  • node:process in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/util/userAgentPlatform.js, ./node_modules/@azure/logger/dist/commonjs/log.js
  • node:stream in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/nodeHttpClient.js, ./node_modules/@azure/core-rest-pipeline/dist/commonjs/util/concat.js
  • node:util in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/util/inspect.js, ./node_modules/@azure/logger/dist/commonjs/log.js
  • node:zlib in ./node_modules/@azure/core-rest-pipeline/dist/commonjs/nodeHttpClient.js

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 avatar Jul 04 '24 21:07 trek-eric

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'],
    }
  }
})

trek-eric avatar Jul 05 '24 21:07 trek-eric