electron-vue icon indicating copy to clipboard operation
electron-vue copied to clipboard

Can't find module in electron.js when pack all the things.

Open SidKwok opened this issue 9 years ago • 5 comments

Describe the issue / bug.

It is FINE when it is on dev mode, but when I do npm run build:mas, it will tells me that can't find the module.

If visual, provide a screenshot.

In electron.js:

const axios = require('axios');
console.log(axios);

When I build the package: 0171a662b848a0c2378de296a4c02282

Tell me about your development environment.
  • Node version: v6.2.0
  • NPM version: 3.8.9
  • vue-cli version: (if necessary)
  • Operating System: macOS 10.12.2 (16C67)

If you need more information, just comment, Thanks~

SidKwok avatar Jan 25 '17 07:01 SidKwok

@SidKwok

The version of electron-vue you used to scaffold you app previously did not support bundling the main process, in other words you can't use any npm packages in electron.js. But good news! A recent update of electron-vue has migrated to using webpack 2 and supports many new features like using npm packages in the main process.

I would recommend scaffolding a new app and transferring over your source files. You can take a look at the milestone here.

SimulatedGREG avatar Jan 25 '17 07:01 SimulatedGREG

Thanks for your feedback. I can import the npm packages now, but there's something wrong with Promise. When I pack: c89999e3f4b4a4fc55fbd7549ff79c63

The whole project had migrated to using webpack 2.

SidKwok avatar Jan 25 '17 09:01 SidKwok

I got the same issue on windows, can't resolve any babel-runtime helper module. Babel-runtime add these helper module import on the top of compiled file.

image

When i install babel-runtime in app dir, i can pack app with no error, maybe webpack search these helper module in app dir. But the packaged app still can't find any third-party modules.

image

abramdev avatar Jan 29 '17 16:01 abramdev

Could you guys try updating .babelrc by moving the transform-runtime plugin so only the renderer environment has it enabled. This might solve the issues but may not be a solid solution. I will be investigating some different settings, that are more specific to the electron environment.

SimulatedGREG avatar Jan 29 '17 19:01 SimulatedGREG

Going to close this for now, since nobody has reported anything back. This may have been related to the official Webpack 2 release as certain dependencies may have needed to update. Did look into modifying babel to target node@^6, but will be holding off on that for now.

SimulatedGREG avatar Feb 28 '17 22:02 SimulatedGREG