Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '***' [Windows] #5

Open
atifkhan161 opened this issue May 10, 2018 · 3 comments
Open

Cannot find module '***' [Windows] #5

atifkhan161 opened this issue May 10, 2018 · 3 comments

Comments

@atifkhan161
Copy link

atifkhan161 commented May 10, 2018

I'm building an app on windows. The app builds successfully and while running app gives the error "Cannot find module "express".
Copying node_modules folder inside resource/app solves the problem.
Dependency saved in package.json is not copied at the time of packaging.

@PKief
Copy link
Owner

PKief commented May 11, 2018

I'm not sure if I understood you correctly. If you want to package the electron application then you run the command e.g. npm run package:win. This command includes a compilation of all angular files to the dist-folder. So now all required dependencies are part of the vendor.bundle.js file in the dist folder. The node_modules are not required anymore to run the application from the dist folder. Finally the electron-packager uses all files from the dist folder to create an executable e.g. "*.exe"-file in the packages folder.

I tried to add some external library to my application, bundled everything to this dist folder and created the packaged files. The command npm run package:win is all I used here and everything worked fine.

I was wondering if you use some direct paths to the node_modules folder in your app? Normally every module should be imported like import * as xyz from 'xyz' right?

@atifkhan161
Copy link
Author

Problem is with node modules like express, axios etc. This dependency is mentioned in the package.json file but is not copied to resources folder.

@vooft
Copy link

vooft commented Sep 27, 2018

The problem in node-only modules, that are not (or can not be) referenced from frontend source files. I believe that angular-cli just ignores them.
Maybe migrating from electron-packager to something more sophisticated would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants