Skip to content
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

Fresh install doesn't work #132

Open
EmilyYond opened this issue Mar 21, 2024 · 1 comment
Open

Fresh install doesn't work #132

EmilyYond opened this issue Mar 21, 2024 · 1 comment

Comments

@EmilyYond
Copy link

I have tried multiple times using npx @sanity/plugin-kit init pluginname, following the wizard, and then when running yarn build it instantly fails (see screenshot below)

Screenshot 2024-03-21 at 12 29 18

All your plugin docs suggest using this but it doesn't work out of the box, so its not a great starting point! Please could someone take a look?

@emmalevesque
Copy link

@EmilyYond I believe I ran into the same issue as you here. I was able to resolve this quickly by rolling back @sanity/pkg-utils to version 5.1.0.

More context

I generated fresh plugin files from the command:

npx @sanity/plugin-kit init sanity-plugin-name
Output:
dependencies:
+ @sanity/incompatible-plugin 1.0.4

devDependencies:
+ @sanity/pkg-utils 5.1.4
+ @sanity/plugin-kit 3.1.10
+ @types/react 18.2.70
+ @typescript-eslint/eslint-plugin 7.3.1
+ @typescript-eslint/parser 7.3.1
+ eslint 8.57.0
+ eslint-config-prettier 9.1.0
+ eslint-config-sanity 7.1.2
+ eslint-plugin-prettier 5.1.3
+ eslint-plugin-react 7.34.1
+ eslint-plugin-react-hooks 4.6.0
+ npm-run-all 4.1.5
+ prettier 3.2.5
+ prettier-plugin-packagejson 2.4.12
+ react 18.2.0
+ react-dom 18.2.0
+ react-is 18.2.0
+ rimraf 5.0.5
+ sanity 3.35.2
+ styled-components 5.3.11 (6.1.8 is available)
+ typescript 5.4.3

 WARN  Issues with peer dependencies found
.
└─┬ @sanity/pkg-utils 5.1.4
  └── ✕ unmet peer typescript@5.4.2: found 5.4.3

Done in 20.2s
[info] Done!

First steps

I first checked the @sanity/plugin-kit change log for any releases that seemed related to the errors I was seeing. Nothing jumped out at me so I returned to the initial output of the plugin generation and noticed:

 WARN  Issues with peer dependencies found
.
└─┬ @sanity/pkg-utils 5.1.4
  └── ✕ unmet peer typescript@5.4.2: found 5.4.3

This being a warning I didn't think was the cause of the issue but it did encourage me to check @sanity/pkg-utils for related releases.

I came across this in the change log:

v5.1.1
5.1.1 (2024-03-20)
Bug Fixes
ensure no "Masquerading as ESM|CJS" dts errors (sanity-io/pkg-utils#627) (e54dc10)

Resolution

Testing to see if this would resolve the build error I pinned @sanity/pkg-utils to the version immediately before 5.1.1 e.g. 5.1.0. I did this by adding the following to my package.json

...
"resolutions": {
    "@sanity/pkg-utils": "5.1.0",
    },
...

Once this change was made I reinstalled my packages and attempted to build the plugin again and it worked!

Clarification

This is definitely not a long-term solution as you'll have to pin @sanity/pkg-utils every time you generate a plugin from @sanity/plugin-kit and further the side effects of rolling this package back to 5.1.0 are unknown but for now this should help you get over the immediate hurdle of not being able to build your plugin.

Hope this is helpful for anyone who comes across this issue as well 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants