question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assets not being inferred or included manually

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12

github_iconTop GitHub Comments

18reactions
reducktedcommented, May 7, 2019

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:

{
    "name": "demo",
    "version": "1.0.0",
    "pkg": {
        "assets": "dist/client/**/*"
    }
}

And running pkg like this:

pkg index.js --targets node10-win-x64

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 run pkg like this:

pkg index.js --targets node10-win-x64 --config package.json

Then the assets are included. 🎉

2reactions
dstampfercommented, Jul 20, 2020

-config package.json saved my day. Did not know that one has to specify that manually.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assets not being inferred or included manually · Issue #647
I have an express API application where the POST routes will upload files into the directory structure temporarily.
Read more >
python-infer
Usually when an import cannot be inferred, it represents an issue like Pants not being properly configured, e.g. targets not set up. Often,...
Read more >
File Sync
Only local source files can be synchronized: files created by the builder will not be copied. It is currently not allowed to mix...
Read more >
Manage Your IPs (Host Assets)
It's best practice to purge a host when the host is being decommissioned or used in a completely new role - new operating...
Read more >
Profiling data assets - IBM Cloud Pak for Data as a Service
Unstructured data assets​​ You cannot manually create or update a profile for an unstructured data asset. In some cases, profile creation is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found