Installing yarn with orb:node2.1.1 install_yarn command not working

I can’t install yarn using the orb “circleci/node@2.1.1” and the command “node/install-yarn” (version 1.22.4)

I get the following logs and error:

Selected version of Yarn is 1.22.4
Checking if YARN is already installed... 
Installing YARN v1.22.4
Verifying YARN install
  throw err;

Error: Cannot find module '/home/circleci/project/.yarn/releases/yarn-1.22.4.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
   at Function.Module._load (internal/modules/cjs/loader.js:862:27)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
   at internal/main/run_main_module.js:18:47 {
  requireStack: []
Something went wrong; the specified version of Yarn could not be installed

Exited with code exit status 1

I am not doing anything fancy, was just trying out orbs…

My config.yml file is shown below:

version: 2.1
  node: circleci/node@2.1.1
      - image: "cimg/base:2020.05"
      - checkout
      - node/install:
          install-npm: false
          node-version: 12.16.2
      - node/install-yarn:
          version: 1.22.4
      - run: node --version
      - run: yarn
      - install-node-12

Hi and welcome to the forum!
Can you also add a build link where this error is being thrown?
Thank you!

Yes absolutely, here it is

It’s funny because if I ssh into it I can see yarn being correctly installed as well as the correct “echo” being logged on the terminal if I copy paste the last part of the yarn-install script.

if yarn --version | grep "$YARN_ORB_VERSION" > /dev/null 2>&1; then
  echo "Success! Yarn $(yarn --version) has been installed to $(which yarn)"
  echo "Something went wrong; the specified version of Yarn could not be installed"
  exit 1

Thanks for the build link! It’s so odd – I copied the config from that red build exactly, and I was able to getting a passing build:

Can you try it again and let me know if you still get a red build? I think there might have been issues with NPM this week.

Also I see that you’re using our next-gen convenience images! Another option is to use the Node 12.16 image, so you won’t have to install Node and Yarn with build:

Hey @annapamela, thanks for your response. No luck so far…

I tried again and still got a red build. That build if needed is here

I then tried the Node 12.16 image instead as recommended, and I also got a red build (see here However, ssh’ing into it and typing “yarn --version” works and shows “1.22.4”.

Hi @andreacab1! Thank you for trying that. This is so odd – especially since it seems to work fine when you SSH into the build!

I tried the exact same config that you’re using with the Node 12.16 cimg image again, and it worked:
Two of my colleagues also tried and got green builds.

Can you try one more time?

Also, can you try running your config without the checkout step? This will help us identify if maybe something is up with yarn.lock or if it is an issue with the executor.

Thank you!

Hey @annapamela,
Just did what you said.

The first time I just retried ( and it failed

The second time, this time without the checkout step ( and it worked!

Not sure what I should do at this point :grimacing:

Additionally, probably worth mentioning that on my local machine I did set the yarn version with

$ yarn policies set-version 1.22.4


Hi @andreacab1 ,

Thanks for trying it! OK so now at least we have ruled out the image. Let’s see if there’s an issue with your yarn.lock file by creating a fresh one. Can you delete your yarn.lock file, re-run yarn install locally, and then push that commit up?


Hey @annapamela,

Thanks for your guys’ help! I realized I hadn’t checked in some of the files that are needed when using yarn. I believe it’s specifically the .yarn/releases/yarn-1.22.4.js that was needed but as the yarn docs suggested, in order to opt in to their “zero-install” feature, there were also others that needed to be checked in.

Anyway, the last build, this time with the checkout step worked!

Thanks again! Really appreciated the help!

PS: here are the yarn docs for what files should be ignored

Hi @andreacab1,

I’m so glad it’s working now!

If you have questions later, you can always submit a support ticket at also!

Happy building!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.