Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No assets after deployment to Vercel #95

Open
sergeyClover opened this issue Feb 19, 2024 · 4 comments
Open

No assets after deployment to Vercel #95

sergeyClover opened this issue Feb 19, 2024 · 4 comments

Comments

@sergeyClover
Copy link

Hello. I have been testing out the application and it seems like asset files such as HTML templates for emails and invoices are not present in .next folder after build.

I tried a few things in next.config.js as well as some testing with changing "copy-standalone" script but nothing seems to work.

Error:Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/assets/invoice/template.html'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '/var/task/.next/server/chunks/assets/invoice/template.html'","code":"ENOENT","errno":-2,"syscall":"open","path":"/var/task/.next/server/chunks/assets/invoice/template.html","stack":["Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/assets/invoice/template.html'"," at Object.openSync (node:fs:596:3)"," at Object.readFileSync (node:fs:464:35)"," at getStaticAssetFile (/var/task/.next/server/chunks/4161.js:96:52)"," at /var/task/.next/server/chunks/7256.js:506:359"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/assets/invoice/template.html'"," at process. (file:///var/runtime/index.mjs:1276:17)"," at process.emit (node:events:529:35)"," at emit (node:internal/process/promises:149:20)"," at processPromiseRejections (node:internal/process/promises:283:27)"," at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
Unknown application error occurred
Runtime.Unknown

Help would be appreciated. :)

@mbpictures
Copy link
Owner

Hi, and thanks for your request!

Your issue is most likely related to this issue of the next.js framework, which is the base of this project:
vercel/next.js#32236

I have followed this issue a long time already and it seems that there's still no viable solution for this, but if you have an idea, please let me know! I "fixed" the issue by moving away from vercel and hosting the project on heroku. Unfortunately, they abounded their free tier.

@sergeyClover
Copy link
Author

Just found out a solution:

  1. Move assets folder to project root
  2. Now assets are accessible with command:
    let basePath = process.cwd();
    const filePath = path.join(basePath, assets/${file});

hope it helps someone in the future ;)

@mbpictures
Copy link
Owner

I'm glad to hear that you found a solution! Do you know if the code works in all three environments: development, production, and standalone production?

@sergeyClover
Copy link
Author

Works in vercel production environment. Didnt test on dev or standalone just yet as it seems that puppeteer is not working as well on vercel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants