-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Cannot find package 'cookie' - Vercel Adapter - hybrid and server outputs #9801
Comments
Hello @fabiobiondi. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Is |
@ematipico I really don't understand what is happening. But a BLANK PAGE, with nothing else inside it, just a label, that use SSR instead, has that "cookie" problem! I will try to create a minimal reproduction project... |
Could you check whether "astro" is under "dependencies" and not "devDependencies"? |
Try |
Due to a bug I introduced, the vercel serverless adapter does not set cookies but the Here is a deployed project that uses |
Astro is located in |
Just updated the export default defineConfig({
site: 'https://www.fabiobiondi.dev/',
output: 'hybrid',
adapter: vercelServerless(),
vite: {
ssr: {
noExternal: 'cookie'
}
},
integrations: [react(), mdx()]
}); |
I have deployed a basic project too without any problem. It works (a simple project like yours with SSR and SSG pages)
So I'm not able to reproduce the issue. PS: i'm using Astro since version 1.x and created many websites, spoken to several conferences and so on.... so I'm not expert but I'm not a newbie either. So this behavior is very strange PPS: I and some friend have another weird problem with Astro 4 and Vercel that we had never had but I'll open another issue about it. The CI doesn't work anymore as before: first Git pushes works fine but after a while (don't ask me the reason) we need to make a build locally and push it too in order to see the updates. But that's another story : ) |
Vercel's CI cache or commands could be interfering as well. You could test this by deleting |
I have tried this again and I have noticed I don't have the error on
|
Here a cleaned repository to reproduce the problem: PAGES: |
That is very unusual. The build did not complete. I am guessing the build completed successfully. I would expect vercel to not create a deployment otherwise. So what I think is happening here is For context, it is a library we use to manage node_modules for the deployment. I've had odd things happen to me during development. There are cases where it neither resolves nor rejects the promises it creates, which results in all code that awaits its result to simply never run and the process eventually exits with code 0.
|
I looked into it again today and I couldn't reproduce it. Turns out the bug is sensitive to the package manager and OS. With npm
With pnpm
I don't have a mac to test on. Do you know if it is any different with a different package manager? Are you deploying using vercel's github app? |
I released one for macos: ❌ https://astro-9801-pnpm-macos.vercel.app/about. I also got an error of: One thing I notice is that the conflicting dependencies are also dependencies of From its deployment logs, it says "Downloading 46 deployment files...". And I can confirm that in One hunch I have is that maybe the deps copied into EDIT: About the OSes, one thing we do know about Linux is that it's a case-sensitive fs. Though I'm unsure how that fits in the picture. |
I'm having the same issue what I was trying to do is to install vercel analytics This config works:
This throws the error:
|
Did anyone find a solution? |
@masaroli If you have a static site, you might be able to use the static adapter instead. import { defineConfig } from "astro/config";
import icon from "astro-icon";
- import vercel from "@astrojs/vercel/serverless";
+ import vercel from "@astrojs/vercel/static";
// https://astro.build/config
export default defineConfig({
- output: "server",
+ output: "static",
integrations: [icon()],
devToolbar: { enabled: false },
adapter: vercel({
webAnalytics: { enabled: true },
}),
}); @ProgrammerLP Unfortunately, not. You can make it so that the SSR App depends less on |
Ah ok, thank you |
i have the same problem. Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'cookie' imported from /var/task/.vercel/output/_functions/entry.mjs |
I had this same problem recently, removing the .vercel/ folder cleared the issue for me. |
Setting the node version on vercel to match my local env was what worked for me. |
This worked, just delete the vercel folder and make a commit and push to your repository and in the deploy vercel will take care of the rest so basically that's how it's solved
package.json astro.config.mjs import vercel from "@astrojs/vercel/serverless"; // https://astro.build/config |
If you have the .vercel folder locally in your project and you get the error "This Serverless Function has crashed", delete the folder and immediately do a commit and push. With that I could solve the problem. 👍 |
Same problema, it is only possible to deploy to the Vercel CLI and not automatically. |
If you read the README.txt inside of .vercel:
|
In my case I solved it by adding the following files to
|
hey guys, I think I found the solution and its working for me too. Just remove the .vercel folder from your local and downgrade the deployment node version from latest 22x to 18x. It will start working. @ematipico I think you can close this issue now 👀 |
@shoaibkh4n It's good that you have a workaround, but downgrading Node isn't a fix. I think this is likely to be a bug in |
I've been investigating this, with @fabiobiondi 's repro (thanks), which I've upgraded to Astro 5. It still exhibited the same issue for me, but once I removed the top level |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I have migrated a website from Astro v.1 (SSG) to v.4 (hybrid).
There are hundred of images, dozens of markdown and more or less 200 Astro components.
Since I had some problems with the migration I decided to create a brand new project with v.4.2.3.
The astro.config.mjs is pretty simple:
Using Static Rendering:
the build works fine in both, locally and deployed on Vercel ✅
Using
hybrid
output:• dev: works ✅
• production (Vercel) ❌: static pages work fine while when I open pages with
export const prerender = false
I got this error:<<
This Serverless Function has crashed.
...
This page just contains the following code:
Using
server
output:• dev: works ✅
• production (Vercel) ❌: all non-static pages have problems
This is the error I read from Vercel Logs, when I visit the SSR page:
In the
.vercel
folder I see that theentry.mjs
file cannot find thecookie
library (but it's available innode_modules
folder:NOTE: I have also tried to install
cookie
on my project as dependency and peer DependencyHave you some ideas or advice?
Thank you 🙏
What's the expected result?
SSR pages should work on Vercel
Link to Minimal Reproducible Example
n/a
The text was updated successfully, but these errors were encountered: