I'm using electron-packager for creating an electron.exe of my app. I need to exclude all node modules . I tried the following
--ignore=node_modules
The above is not working. Any idea how to exclude all folders/ remove node modules in final build.
No, You don't need to push your node_modules folder to production whether it is a static export or dynamic build. When you export a static build the source file is converted into HTML & js files. So there is no need for node modules on production env.
The node_modules folder contains every installed dependency for your project. In most cases, you should not commit this folder into your version controlled repository. As you install more dependencies, the size of this folder will quickly grow. Furthermore, the package-lock.
The node-pre-gyp tool provides a way to deploy native Node modules with prebuilt binaries, and many popular modules are using it. Sometimes those modules work fine under Electron, but when there are no Electron-specific binaries available, you'll need to build from source.
If you install modules as devDependencies
, they will all be pruned automatically before packaging.
If you're using electron-builder
you can define glob patterns as files
in the config. In this case !**/node_modules/*
will exclude all of node_modules
.
If you're using electron-packager
you can use the ignore
option and regular expression to exclude files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With