Electron-vue: Can't use npm modules inside electron.js

Created on 30 Oct 2016  路  3Comments  路  Source: SimulatedGREG/electron-vue

Describe the issue / bug.

Can't use npm modules inside electron.js. _(socket.io for example)_

I know the node_modules are removed in the final build, but they seem to work only when included inside the Vue instance.

Is there some way i can still require these in electron.js?

How can I reproduce this problem?
npm install --save socket.io
cd app 
npm install --save socket.io
npm run build:win32
# then execute exe

/app/electron.js

const io = require('socket.io')
If visual, provide a screenshot.

image

Tell me about your development environment.
  • Node version: 6.5.0
  • NPM version: 3.10.8
  • Operating System: Win 10
question

Most helpful comment

Looking to bring electron-builder support soon, which should make external modules for main process a lot easier to manage. Not many boilerplates handle this well so there is some pioneering to do since webpack is involved. Thanks for understanding.

All 3 comments

@simonwjackson

Any modules required within the scope of app/src/main.js will be bundled with webpack for the renderer process only. Modules required in app/electron.js will not work in production, after making a build. There's currently no plans to support bundling the main process at the moment (more info).

Related:

22

Ok, i guess ill have to write a script to install dependencies after the build is complete since this is mission critical for my app.

Thanks or the update!

Looking to bring electron-builder support soon, which should make external modules for main process a lot easier to manage. Not many boilerplates handle this well so there is some pioneering to do since webpack is involved. Thanks for understanding.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pansila picture pansila  路  3Comments

okwangyu picture okwangyu  路  3Comments

blackw212 picture blackw212  路  3Comments

jt-wang picture jt-wang  路  3Comments

Oriol-GG picture Oriol-GG  路  3Comments