Output standalone mode not omtimizing images?
See original GitHub issueVerify 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:
- Created a year ago
- Comments:15 (6 by maintainers)
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.
After doing above step, I just again run build. This time it worked successfully!.
I am closing my issue.
Specially thanks
to @balazsorban44If don't help me, I can't solve that problem. Thank you very much. You are really a good person. Thanks again
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.