'Electron builder not copying my dist/node_modules directory in the right place
I've got one node application which I'm already launching with Electron. Now, I want to package it with electron-builder, but I'm dealing with such an strange behaviour. Usually, when I build my application, a dist folder gets generated, containing all the transpiled javascript files and also the package.json. Then, I have to run npm i --production again there to set up my production dependencies. So what I want electron-builder to do is to copy exactly the dist directory as it is once everything is installed:
electron-builder build --linux AppImage
This is my package.json related config:
"main": "dist/app.js",
"build": {
"appId": "my.app",
"files": [
"dist/**/*"
]
},
I guess that with this configuration I'm telling it to copy the dist directory and its contents. The AppImage file gets built and if I unzip it, I can see a resources dir gets created inside, containing one app.asar file. If I extract the asar content, I can see node_modules gets placed at the same level than dist, and not inside of it!! So I have:
AppImage
-- resources
---- app.asar
------ node_modules
------ dist (everything except node_modules)
When I launch the application it obviously complains of not finding the node_modules. The docs say there's some default files pattern which can take precedence of what user has defined...
I also have tried:
"files": {
"from": "dist",
"to": "dist",
"filter": ["**/*"]
}
And seems not being able to find the package.json file.
Somebody asked this similar question years ago, with no answer. Any help please?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
