Multiple versions of @sanity/generate-help-url from block-content-to-hyperscript

25 replies
Last updated: Sep 1, 2022
Hey everyone, I am having an issue after updating a bit of an older project. I am getting a multiple versions issue for @sanity/generate-help-url. The old version is being called from ./~/@sanity/block-content-to-hyperscript/~/@sanity/generate-help-url, however, I am not using block-content-to-hyperscript anywhere. Wondering if that needs to be updated in the core Sanity package?
AI Update

This is a dependency conflict issue that's actually not a problem with your code, but rather with an outdated transitive dependency. Here's what's happening:

The @sanity/block-content-to-hyperscript package is deprecated and has been replaced by modern alternatives. Even though you're not directly using it in your project, some older Sanity package might still have it as a dependency, which is causing the version conflict with @sanity/generate-help-url.

Solution

The best approach is to migrate away from the deprecated packages. According to the official Sanity documentation, here are the modern replacements:

For rendering Portable Text:

  1. For HTML: Use @portabletext/to-html instead of @sanity/block-content-to-html or @sanity/block-content-to-hyperscript

  2. For React: Use @portabletext/react instead of @sanity/block-content-to-react

  3. For other frameworks: There are modern packages for Vue, Svelte, React Native, and Astro

Immediate workarounds:

If you can't migrate immediately, try these:

  1. Use npm resolutions (in package.json):
{
  "resolutions": {
    "@sanity/generate-help-url": "^3.0.0"
  }
}
  1. Use yarn resolutions or npm overrides to force a single version

  2. Clear your lock file and reinstall:

rm -rf node_modules package-lock.json
npm install

Long-term fix:

Check which Sanity packages you're using and update them to their latest versions. The core Sanity packages have been updated to remove dependencies on these deprecated packages. Run:

npm outdated

Then update your Sanity packages:

npm update @sanity/client sanity

The block-content-to-hyperscript package is no longer maintained by Sanity, so this isn't something that will be "fixed in the core Sanity package" - it's been replaced by the modern Portable Text tooling mentioned above.

Show original thread
25 replies
@sanity/block-content-to-hyperscript

It looks like the dependencies are outdates in hyperscript
Hey
user K
! Can you try deleting your node_modules and lock file, then reinstalling?
Hey RD, I have done that quite a few times before messaging here. I will give it another go though, this is what my dependencies are at 🙂
Just deleting and reinstalling now
This may be unrelated since the issue seems to come from your hyperscript plugin, but I wonder if one issue is that block content to react is being deprecated in favor of this new plugin .
Ahh so true, ok thank you 🙂 I will update that plugin and see if it fixes it up 🙂
user M
, I am running into this issue when trying to run portable-text Ecmascript modules
Any idea where that would be coming from?
No, and I can't find any mention of that in the repo. I'll keep looking though!
Thank you, I have a feeling it's because this is a very old create react app running in JS not TS. It's a bit of a fragile one, but we are slowly making our way through an update.
I have simplified my setup and rolled back to the last commit where I updated all the @sanity libraries. But now getting an issue that I have had in the past couple of days with sanity-help-url
generateHelpUrl is not a function {"error":{"message":"generateHelpUrl is not a function","name":"TypeError","stack":"TypeError: generateHelpUrl is not a function\n at Object../node_modules/@sanity/client/lib/warnings.js
Ok, looking at this past issue , installing this package may fix it.
This is where it gets into a bit of a loop. If I add the latest package of generate help then block-to-hyperscript throws the multiple packages error with @sanity/block-content-to-hyperscript requiring a lower version of help url. I will give "resolutions" [] a try to see if I can resolve the versions.
We are about to start rebuilding the front end but just need to resolve this update so we can get a backlog bug fixed
😄
What version of React are you on?
"react": "^16.9.0",
Yeah it looks like the loop of block-content-to-react -> block-content-to-hyperscript -> @sanity/generate-help-url which requires ^0.140.0.
Is @sanity/block-content-to-hyperscript deprecated now as well as block-content-to-react
No, we're still recommending it.
Are you able to share your repo?
user M
, I would be happy to, but need to be in a private channel as it's a clients repo.
For sure! Feel free to DM me. My day is ending here, though, so I won't be able to take a look until tomorrow.
Hey
user M
, ok no worries at all 🙂 I have managed to bypass it temporarily by loosening the jest tests for now. I think with the amount of effort to resolve this, knowing there is a rebuild starting very shortly, we might just have to create a few workarounds for now 🙂
But I will let you know how the testing goes and share the repo tomorrow if I still need. Thanks so much for your help today though
Happy to help! And do let us know if you want more help!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?