-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
Serverless build requires missing critters dependency, which causes netlify deploy to fail #20742
Comments
Hello 👋 Erez from Netlify here. TLDR for the cause: A recent change added See here and here for reasons not to include it. We have an active discussion on how to avoid such cases in the future.
|
Thanks @erezrokah. I can confirm that your fix works for us. Do I understand it correctly, that |
Glad to hear that @frigus02 and thank you for confirming.
Yes I think the issue is still valid. Any bundler would probably run into this issue. |
Going to close this given that the particular critters require is optional (part of an experimental feature) and as such in an |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.0.4
What version of Node.js are you using?
15.5.0
What browser are you using?
any
What operating system are you using?
macOS, Linux
How are you deploying your application?
next build && next-on-netlify && netlify deploy
Describe the Bug
We deploy a Next.js application using the serverless target to Netlify. It worked on 10.0.3, but fails on 10.0.4.
The
netlify deploy
command errors with:It seems the issue is that a
require("critters")
is added to thenext build
serverless output. We can see that here:We assume this is because the following code is not removed by the JS minifier:
next.js/packages/next/next-server/server/render.tsx
Lines 1093 to 1095 in ad1150d
We tried to change this to use the environment variable which caused the code to be removed on the next build. But we haven't tested if the optimizeCss feature still works 🙂.
The issue has also been reported here: https://community.netlify.com/t/issue-while-deploying-next-app/28861. As mentioned installing "critters" as a dev dependency is another workaround.
Our understanding is that this is an issue of Next.js. Please let us know if we should report this on the Netlify CLI instead.
Expected Behavior
The next build output does not include critters if the optimizeCss feature is not enabled.
To Reproduce
Create example app:
Change build target to serverless:
Build and find critters in the output:
To reproduce the Netlify error install
next-on-netlify
andnetlify-cli
and attempt to deploy the application:The text was updated successfully, but these errors were encountered: