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.

Output standalone mode not omtimizing images?

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Hello, I use automatically coping traced file for deploying my site to ec2 server. I follow this documentation-

https://nextjs.org/docs/advanced-features/output-file-tracing#automatically-copying-traced-files

Here first of all I updated my next.config.js file-

module.exports = {
  output: 'standalone',
}

Then after building I manually copy static folder to standalone/.next/ and also copy public folder to standalone/. After copying the run node server.js. It running successfully. But image optimization not working.

In terminal I found this error-

Error: 'sharp' is required to be installed in standalone mode for the image optimization to function correctly

But When I check standalone/package.json and standalone/node_modules I can see It already have sharp package.

Then after some researching, i also add a environment varriable to standalone/.env file as NEXT_SHARP_PATH=/tmp/node_modules/sharp next start

Image optimization still not working.

I try to some different way - NEXT_SHARP_PATH=/tmp/node_modules/sharp next standalone, NEXT_SHARP_PATH=/tmp/node_modules/sharp standalone, NEXT_SHARP_PATH=/node_modules/sharp, NEXT_SHARP_PATH=/tmp/node_modules/sharp

Still image optimization not working. How can I fix that problem.

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Image optimization not working on standalone output

Expected Behavior

It should work in standalone mood

Link to reproduction

https://github.com/nekmart/nekmart-reproduction https://nekmart.com/

To Reproduce

NEXT_SHARP_PATH=/tmp/node_modules/sharp next standalone,

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nekmartcommented, Oct 4, 2022

I think it worked now successfully. Problem occured in webpack. Before outpur tracing process, I host this project to aws amplify. Aws amplify told me to install webpack as dependency. By uninstalling webpack it worked successfully now.

  1. I can’t clearly say that problem occurred for webpack only.
  2. I also update my project to latest next version.
  3. I also clear some code in next config
  4. I also remove NEXT_SHARP_PATH from environment varriable

After doing above step, I just again run build. This time it worked successfully!.

I am closing my issue.

Specially thanks to @balazsorban44 If don't help me, I can't solve that problem. Thank you very much. You are really a good person. Thanks again

0reactions
github-actions[bot]commented, Nov 3, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs output tracing system (standalone mode) not optimizing ...
I create a dashboard site for uploading new assets(Like product, category, brand etc). I can see that only the new image are not...
Read more >
Image optimization not working for all images in standalone ...
Here the bug is very critical. I create one project and I deploy this project to vercel. Here I get all images are...
Read more >
sharp-missing-in-production - Next.js
You are seeing this error because Image Optimization in standalone mode ( output: "standalone" ) was detected. Possible Ways to Fix It. Install...
Read more >
How To Optimize Images for Web and Performance - Kinsta
Best Practices for Optimizing Images for the Web. Here are some general best practices when it comes down to how to optimize images...
Read more >
Optimize-WindowsImage (DISM) - Microsoft Learn
Specifies the full path to the root directory of the offline Windows image that you will service. If the directory named Windows 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