Assets not being inferred or included manually
See original GitHub issueI have an express API application where the POST routes will upload files into the directory structure temporarily. The files are uploaded into a folder called /uploads
. In my code I have the following line:
const filePathToMedia = path.join(__dirname, `../uploads/${apiFile}`);
which from my understanding of the documentation should auto-detect or infer that this directory /uploads
should be included with the pkg when generating the executable.
However this doesn’t appear to be happening. I get the following error when testing the POST route of my API:
message:
'Error: form-data: File or directory \'C:\\**\\app-name\\uploads\\test.wav\' was not included into executable at compilation stage. Please recompile adding it as asset or script.',
This led me to think that maybe I needed to run pkg package.json
vs pkg app.js
and manually define my assets instead of depending on auto-detection of path.join to resolve them for me.
so I include this following in my package.json:
"bin": "app.js",
"pkg": {
"assets": ["uploads/**/*"]
},
However, I still get the same issue. Any ideas on what else I should try or to get my /uploads
directory included? Any help would be really appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12
I was having the same issue with assets not being included, but the suggestion from @isaelblais led me to the solution. I had this in my
package.json
:And running
pkg
like this:But the assets weren’t being included. As it turns out, the
package.json
file doesn’t seem to be used as a config file automatically. If I runpkg
like this:Then the assets are included. 🎉
-config package.json saved my day. Did not know that one has to specify that manually.