I 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.
I 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:which from my understanding of the documentation should auto-detect or infer that this directory
/uploadsshould 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:
This led me to think that maybe I needed to run
pkg package.jsonvspkg app.jsand 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:
However, I still get the same issue. Any ideas on what else I should try or to get my
/uploadsdirectory included? Any help would be really appreciated.