question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Impossible to use `sanity install <plugin-name>` when using Yarn 2

See original GitHub issue

Describe the bug

In my project, I recently migrated to Yarn 2 (without PnP, so still using node_modules). It is a Yarn Workspaces monorepo and everything works fine. However, I just discovered than since then, I am unable to install plugins for Sanity with the official CLI.

Unfortunately, I can’t supply the code here as it is a private repo. I could do a minimal reproduction repo if necessary, but the error is pretty self-explanatory:

➜ yarn sanity install content-calendar
✖ Resolving dependencies
✖ An unexpected error occurred: "Unknown token: { line: 3, col: 2, type: 'INVALID', value: undefined } 3:2 in /Users/my-username/Projects/my-repo/yarn.lock".
✖ Resolving dependencies

Error: Command failed :(
    at ~/Projects/my-repo/node_modules/@sanity/cli/bin/sanity-cli.js:3260:2554

My guess on the issue is that the Yarn version bundled with the CLI completely ignores the Yarn 2 installation in the repository. Since the yarn.lock file structure changed in Yarn 2 (see this link for more info), I think that the bundled Yarn package in the CLI just fails on reading the lockfile.

To Reproduce

  1. Have a working Sanity Studio
  2. Migrate to Yarn 2: yarn set version berry and the following content in .yarnrc.yml:
    nodeLinker: node-modules
    yarnPath: .yarn/releases/yarn-berry.cjs
    
  3. Run sanity install <my-plugin-name>

Expected behavior

The plugin should be installed without any error.

Which versions of Sanity are you using?

@sanity/cli              2.1.4 (up to date)
@sanity/base             2.1.4 (up to date)
@sanity/cli              2.1.4 (up to date)
@sanity/components       2.1.4 (up to date)
@sanity/core             2.1.4 (up to date)
@sanity/default-layout   2.1.4 (up to date)
@sanity/default-login    2.1.4 (up to date)
@sanity/desk-tool        2.1.4 (up to date)
@sanity/ui              0.32.4 (up to date)
@sanity/vision           2.1.4 (up to date)

What operating system are you using? MacOS 11.1 / Google Chrome 87

Which versions of Node.js / npm are you running?

➜ npm -v && node -v
6.14.8
v12.20.0

➜ yarn -v
2.4.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
TheKnarfcommented, Jan 20, 2021

I have the same problem. Our repo is public so you can test it here: https://github.com/Alv-no/alv-website

1reaction
qinyiyaocommented, Oct 13, 2021

Same problem, any workaround?

Currently I’m opting out of PnP for the Sanity Studio package in a monorepo, following Yarn’s instruction: https://yarnpkg.com/getting-started/recipes#hybrid-pnp--node_modules-mono-repo

There’s no need to bother with sanity install. You can just manually add the plugin name to sanity.json after yarn add.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to make sanity cli use npm rather than yarn?
Is it possible to make sanity cli use npm rather than yarn? ... Using both hasn't hurt so far, but it does feel...
Read more >
@sanity/client | Yarn - Package Manager
Client for retrieving, creating and patching data from Sanity.io ... Sanity Client requires the JavaScript runtime to have a global ES6-compliant Promise ...
Read more >
Nixpkgs 22.11 manual - NixOS
Nix expressions describe how to build packages from source and are collected in the nixpkgs repository. Also included in the collection are Nix...
Read more >
Building Custom Viz Plugins in Superset v1 - Preset.io
If you choose timeseries, your plugin will be set up with the ... Use your terminal to cd into superset-ui; Run yarn install...
Read more >
Documentation 6.2 - Zabbix
Distributed monitoring deals with the possibilities of using Zabbix in ... It is possible to link additional templates and add more tags and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found