Error in installing sanity-plugin-icon-picker 2.1.0 due to dependency issue

5 replies
Last updated: Jun 2, 2023
Hi team, I am using sanity v2. I installed sanity-plugin-icon-picker 2.1.0. Then I got this wierd error. Hope to find help here. Thanks!
Error in ./node_modules/react-virtualized-auto-sizer/dist/react-virtualized-auto-sizer.esm.js

Module parse failed: Unexpected token (326:6)

You may need an appropriate loader to handle this file type.

|       style = {},

|       tagName = "div",

|       ...rest

|     } = this.props;

|     const {

@ ./node_modules/sanity-plugin-icon-picker/dist/components/SearchResults.js 20:56-95

@ ./node_modules/sanity-plugin-icon-picker/dist/index.js

@ ./node_modules/sanity-plugin-icon-picker/dist/schemaType.js

@ ./node_modules/sanity-plugin-icon-picker/dist/schemaType.js (all:part:@sanity/base/schema-type)

@ ./schemas/schema.js (part:@sanity/base/schema)

@ ./node_modules/@sanity/vision/lib/SanityVision.js

@ ./node_modules/@sanity/vision/lib/VisionTool.js

@ ./node_modules/@sanity/vision/lib/VisionTool.js (all:part:@sanity/base/tool)

@ ./node_modules/@sanity/default-layout/lib/util/getRegisteredTools.js

@ ./node_modules/@sanity/default-layout/lib/router.js

@ ./node_modules/@sanity/default-layout/lib/Root.js (part:@sanity/base/root)

@ ./node_modules/@sanity/base/lib/components/SanityRoot.js (part:@sanity/base/sanity-root)

@ ./node_modules/@sanity/server/lib/browser/entry-dev.js

@ multi ./node_modules/@sanity/server/lib/browser/entry-dev.js
Jun 1, 2023, 4:42 PM
Hi
user D
. Unfortunately, this will happen as more packages update to ES6 syntax (in the error above, it’s the
…rest
line) without polyfills for ancient bundlers like Webpack 3 (which is what v2 of the Studio uses). In this case, the
icon-picker
plugin depends on
^1.0.5
of
react-virtualized-auto-sizer
, meaning that it will update the dependency for anything up to but excluding
v2.0.0
. It looks like this PR made what ended up being breaking changes to the v2 version of the
icon-picker
plugin. Given the plugin’s package.json refers to
v1.0.5
of the dependency, I would try pinning to that by adding this to your Studio’s
package.json
file and running `npm i`:

"overrides": {
  "sanity-plugin-icon-picker": {
    "react-virtualized-auto-sizer": "1.0.5"
  }
}
If you’re using yarn, you can change
overrides
to
resolutions
and install accordingly.
Jun 1, 2023, 5:37 PM
If you can upgrade your Studio to v3, you won’t run into this problem anymore.
Jun 1, 2023, 5:37 PM
Thanks
user A
for a detailed feedback.
Jun 2, 2023, 12:53 AM
We are maintaining a legacy codebase 🙂We might be pushing for v3 sometime to take advantage of the new features.
🙂
Salamat!
Jun 2, 2023, 12:59 AM
I used the 2.0.0 versions instead and it solves the issue. 🙂
Jun 2, 2023, 1:09 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?