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.

'yarn set version berry' requires deletion of .yarnrc.yml

See original GitHub issue
  • I’d be willing to implement a fix

Describe the bug

Sometimes I am trying to install berry. I may have copied some config files over to a repo that wasn’t previously using berry, or I may have changed some stuff in a monorepo and, for whatever reason, berry isn’t installed and .yarn is not present.

To Reproduce

Problem 1:

  • Attempting to install berry will error if the .yarnrc.yml is present:
> yarn set version berry
node:internal/modules/cjs/loader:928
  throw err;
  ^
Error: Cannot find module '.yarn/releases/yarn-berry.cjs'
  • To get around it I use a silly file called .yarn-bootstrap.sh:
#!/bin/sh
mv .yarnrc.yml .yarnrc.yml.bak
touch .yarnrc.yml
yarn set version berry
yarn plugin import workspace-tools
mv .yarnrc.yml.bak .yarnrc.yml

This script should not be needed and berry should be resilient to install without requiring a deleted config file.

Problem 2:

  • Plugins specified in the .yarnrc.yml cannot be installed without removing them from the .yarnrc.yml:
> yarn plugin import workspace-tools
Internal Error: Cannot find module '.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs'
Require stack:
- .yarn/releases/yarn-berry.cjs

An easy version for the user could be for the yarn command to automatically download the berry release and plugins specified in .yarnrc.yml if they are missing.

Issue Analytics

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

github_iconTop GitHub Comments

16reactions
icaro-capobiancocommented, Mar 8, 2021

Tools like this shouldn’t require you to add binary files to your repo, config files should be enough

12reactions
arcaniscommented, Feb 13, 2021

That expectation is false and it does not even apply here and you can not assume that using a repository with a yarn binary already checked into it is the only thing that I can possibly ever be doing.

I mean, that’s our tool, so if we tell you how to use it but you prefer to ignore recommendations and do differently, it’s fine, but you have to expect that you may not hit the happy path, and thus have to build some additional scripts to get the logic you want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration options | Yarn - Package Manager
List of all the configuration option for Yarn (yarnrc files)
Read more >
yarn install leads to Cannot find module yarn-berry.js
After you run yarn set version stable and you add nodeLinker: node-modules to the .yarnrc.yml file, you need to run yarn install again....
Read more >
Configure and use Yarn with CodeArtifact - AWS Documentation
The following procedure details how to configure Yarn 2.X by updating your .yarnrc.yml configuration from the command line with the yarn config set...
Read more >
Javascript/Nodejs/yarn-plugin-apt - Debian Wiki
Creating a yarn plugin to resolve node modules installed as debian packages via ... yarnpkg set version berry $ if ! grep nodeLinker...
Read more >
Using yarn v2 berry with create-react-app - Leo Pradel
We need to tell yarn that we want to use berry for this project. yarn set version berry. Now let's install our dependencies...
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