#Upgrading to 5.0 from 4.16.7 - Breaks

109 messages · Page 1 of 1 (latest)

lime tangle
#

I had to back out of the upgrade because it completely broke my site. ("Back out" in this case means restore from a system backup, so..somewhat brute force)

Is there a more pleasant path to upgrading? Is it possible to generate a report specifying what is causing the breaking?

final flint
#

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.

lime tangle
#

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

final flint
#

Oh weird. Could have needed to delete node_modules/ and maybe the .astro/ directory

lime tangle
#

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!)

final flint
#

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?

lime tangle
#

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.

final flint
#

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)

lime tangle
#

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.

lime tangle
#

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.

#

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

final flint
#

So both of those error messages are saying you still have Astro 4 installed so can’t install the newer versions.

lime tangle
#

Yeah, it's a bit of a circular thing because I get the error when I try to update astro

final flint
# lime tangle

You probably need to update all the dependencies together. Could you try running exactly the command suggested at the bottom here?

lime tangle
#

Sure, I'll try that again.

#

erm...

I think I need to start over..

final flint
#

No no, we’ll battle through! 😄

lime tangle
#

Oh, okay..

final flint
#

Could you share what your astro.config.mjs looks like?

lime tangle
final flint
lime tangle
#

That caused a series of errors. I can run it again and share those with you

final flint
#

Yeah, please do!

lime tangle
final flint
final flint
# lime tangle

Ahhh, OK, so I guess you also need Svelte 5 instead of Svelte 4.

lime tangle
#

Huh..

final flint
lime tangle
#

Okay, stand by..

final flint
#

OK, I’m confused 😅

lime tangle
#

Yeah! Me too!

final flint
#

It says in those screenshots “root project”. Is this a monorepo?

lime tangle
#

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

final flint
#

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?

lime tangle
#

No, that's not the case. One repo. One package.json, etc.

final flint
#

OK, then I guess that’s just standard wording.

#

OK first principles then. Could you share package.json?

lime tangle
#

Oh. That's where this 'deeply-debris' idiom is coming from.

final flint
#

Haha yeah your package name 😄

lime tangle
#

Yeah..

final flint
#

Going to run npm install on this and then see if I can get it to upgrade 🤞

lime tangle
#

Okay

final flint
#

Hitting the same thing. I’m wondering if it’s due to a subdependency. Going to try and debug.

lime tangle
#

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.

final flint
#

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-embed and @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.0 to its peerDependencies field in package.json
  • If you want to try the project ahead of time, npm install --force will 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:

lime tangle
#

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?

final flint
#

Yeah, that should update the lock file for you

final flint
#

Huh. And this is with the updated package.json?

lime tangle
#

Hrm..I'm fairly certain. But let me redo that just in case I saved it to the wrong place. (Getting a bit bleary..)

final flint
#

If it’s still the same error, maybe try deleting the package-lock.json as well for good measure.

lime tangle
#

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?

final flint
lime tangle
#

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?

final flint
#

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?

lime tangle
#

./netlify/functions/package-lock.json

final flint
#

Oh. Wonder if that’s an issue. Is there a package.json in that folder too?

lime tangle
#

❯ ls netlify/functions
package-lock.json package.json sendgrid

#

Yes

final flint
#

What’s it got as dependencies?

lime tangle
#

"@sendgrid/mail": "^8.1.3"

#

In package.json we have:

    "@sendgrid/mail": "^8.1.4",
#

🤷🏽‍♂️

final flint
#

Hm. Seems like it should be fine tbh

lime tangle
#

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.

lime tangle
#

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
  },
final flint
#

Ah yeah. You can just remove the contentLayer line

#

And the output: 'hybrid'

lime tangle
#

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"

final flint
#

Yeah at this point going through the migration guide is probably a good idea.

lime tangle
#

Check!

final flint
#

But glad at least the npm hell hurdle is cleared!