#Upgrading to 5.0 from 4.16.7 - Breaks
109 messages · Page 1 of 1 (latest)
Usually you'd need to read the error logged when it breaks, either in dev or build mode.
Sounds like you're not using something like Git to track changes? That could also make things a bit yes painful to switch back to an old version when necessary.
I am definitely using Git to track changes, for sure.
I attempted to restore package, package-lock and then did a build, but the build failed in a way that indicated it had something to do with the upgrade.
package and package-lock were the only changed files according to git
Oh weird. Could have needed to delete node_modules/ and maybe the .astro/ directory
Yeah, that's what I was thinking. I'd be happy to try again. (I thought I had copied the error log to a file for reference, but evidently I did not..)
(I panicked!)
But yeah, regarding how to work out what's up. I usually read the error log and try to figure it out from there. Maybe you could share that here?
I'll do that, definitely.
There was some mention of experimental features. I was also going through the upgrade guide/post and there seem to be quite a few things to pay attention to. My hunch was that the upgrade automation would handle any of these — but I could be wrong. For instance, the Content Layer update.
Ah yeah. Probably needs some changes to the config file. The upgrade command only takes care of installing the new versions of dependencies, not also updating any of your config/code.
(that would be cool, but I have a feeling we'd break things more often than not trying to do that automatically)
Okay. There seem to be quite a few changes that would need to be made. Probably best to do this in an upgrade_v5 branch or some such.
So I cloned the repo in a separate location and now will try to run the update. This all seems fine so far.
I'm not sure what specifically the breaking changes might be of course.
Okay, this is the same error as before.
I suspect the manual process will yield the same failure.
When I try to install @astrojs/[email protected] there's a hard fail
Svelte as well
I'm not sure if these are systemic issues or something to do with my particular installation. (Which otherwise runs fine on the latest v4
So both of those error messages are saying you still have Astro 4 installed so can’t install the newer versions.
Yeah, it's a bit of a circular thing because I get the error when I try to update astro
You probably need to update all the dependencies together. Could you try running exactly the command suggested at the bottom here?
No no, we’ll battle through! 😄
Oh, okay..
Could you share what your astro.config.mjs looks like?
Just to double check, you ran this before to update all these packages, right?
npm install @astrojs/[email protected] @astrojs/[email protected] @astrojs/[email protected] @astrojs/[email protected] @astrojs/[email protected] [email protected] @astrojs/[email protected]
That caused a series of errors. I can run it again and share those with you
Yeah, please do!
Because I think this error is just that the wrong version of the MDX package is installed. But I’m not sure why/how exactly. So seeing what happend will help.
Ahhh, OK, so I guess you also need Svelte 5 instead of Svelte 4.
Huh..
Try adding svelte to the command too:
npm install @astrojs/[email protected] @astrojs/[email protected] @astrojs/[email protected] @astrojs/[email protected] @astrojs/[email protected] [email protected] @astrojs/[email protected] svelte@^5.1.16
OK, I’m confused 😅
Yeah! Me too!
It says in those screenshots “root project”. Is this a monorepo?
Um...I'm not sure how to answer that. I feel like I should be able to say, but I'm not entirely sure?
I mean, it's one repo
Ah, sorry. A “monorepo” is a repo that has multiple “packages”, i.e. subdirectories that contain their own package.json. I’m guessing that’s not the case?
No, that's not the case. One repo. One package.json, etc.
OK, then I guess that’s just standard wording.
OK first principles then. Could you share package.json?
Haha yeah your package name 😄
Yeah..
Going to run npm install on this and then see if I can get it to upgrade 🤞
Okay
Hitting the same thing. I’m wondering if it’s due to a subdependency. Going to try and debug.
Dang. Okay..
I was trying to discern what might be breaking things, but there seemed to be a slew of deprecation warnings and such, and I just got lost.
Yeah, it’s one of the more complicated upgrades I’ve seen.
So, what I discovered:
- I had to delete
node_modules/to get anywhere while upgrading, so that probably needs doing first. - You have two dependencies that haven’t been updated to allow Astro v5 in their peer dependencies:
astro-lazy-youtube-embedand@philnash/astro-pagination. The first one maybe you can remove? You already have@astro-community/astro-embed-youtube, so could potentially use just that unless you needed both for some reason. The second will need updating — perhaps you could send a PR adding^5.0.0to itspeerDependenciesfield inpackage.json - If you want to try the project ahead of time,
npm install --forcewill force an install even though those two dependencies strictly speaking say they don’t support v5 (very probably they do in practice though)
Here’s the package.json I ended up with. You could just replace your existing one with this, delete node_modules/ and install:
Okay. Going to try that.
I'm going to delete the astro-pagination — I'm not entirely sure where I use that. It may be an old fiddle.
So, just to be clear..now do npm install
Leave package-lock.json as is?
Yeah, that should update the lock file for you
Huh. And this is with the updated package.json?
Hrm..I'm fairly certain. But let me redo that just in case I saved it to the wrong place. (Getting a bit bleary..)
If it’s still the same error, maybe try deleting the package-lock.json as well for good measure.
Yeah. Same thing. (it has "astro" : "^5.0.2" in it, but I re-downloaded it just in case..)
And no node_modules folder
It doesn't seem like it did much except check for resolution errors?
Yeah that’s expected. So deleted the lock file, ran npm i and got this same error?
Yep
Oh, wait.
No — I hadn't deleted the lock file
Let me try yet again..
Oh, I guess I had deleted it. Yes — sorry. Same error.
And what you're seeing is that with an empty project with this package.json, you get a good build?
Well, I get the packages to install. (Either by removing those two dependencies I mentioned above or by running npm install --force.)
There’s no more code in the folder, so not actually building anything
Ooh. Random thought. Do you have lock files for any other package managers in there by any chance? like a pnpm or Yarn lock file?
./netlify/functions/package-lock.json
Oh. Wonder if that’s an issue. Is there a package.json in that folder too?
What’s it got as dependencies?
"@sendgrid/mail": "^8.1.3"
In package.json we have:
"@sendgrid/mail": "^8.1.4",
🤷🏽♂️
Hm. Seems like it should be fine tbh
Dang. I wish there was something obvious.
I guess this is expected? There's no astro found at this point. So when I try to do a build, it just fails sh: astro: command not found
Oh, wait. I didn't take out the astro-lazy-youtube-embed. I use that, but it's not mission critical. Maybe I messed up when I re-downloaded the package.json or something. npm install seems to be trying harder tis time.
Oh, huh. It took hold this time. Let me try to build now.
Okay, now this, but I think this is a step I am meant to take in any case:
Metadata for 687 content files written to /Users/julian/Code/nfl-backoffice-astro-5/src/generated/content-metadata.json
[config] Astro found issue(s) with your configuration:
! experimental Invalid or outdated experimental feature.
Check for incorrect spelling or outdated Astro version.
See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags for a list of all current experiments..
! output Invalid input.
With my current astro.config.mjs I have:
experimental: {
contentIntellisense: true,
contentLayer: true
},
Ah. Check.
Okay. Cleared the build. A bunch of router warnings when I run dev. I guess these are things that need to be fiddled with, presumably. (Read the update docs, etc.)?
And there's a bunch of things to do as regards content collections to bring them into the new content set up, I'm pretty sure.
But, it builds and it runs, albeit with 4.0 collections idioms so a bunch of stuff is "missing"
Yeah at this point going through the migration guide is probably a good idea.
Check!
But glad at least the npm hell hurdle is cleared!