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
internal/modules/cjs/loader.js:983
  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 {
  code: 'MODULE_NOT_FOUND',
  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
orbs:
  node: circleci/node@2.1.1
jobs:
  install-node-12:
    docker:
      - image: "cimg/base:2020.05"
    steps:
      - checkout
      - node/install:
          install-npm: false
          node-version: 12.16.2
      - node/install-yarn:
          version: 1.22.4
      - run: node --version
      - run: yarn
workflows:
  install-n:
    jobs:
      - 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 https://circleci.com/gh/andreacab/studiodeville-frontend/10.

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)"
else
  echo "Something went wrong; the specified version of Yarn could not be installed"
  exit 1
fi

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: https://app.circleci.com/pipelines/github/annapamma/sandbox/392/workflows/756979b0-84d8-4e35-b456-b7522f914104/jobs/619.

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: https://hub.docker.com/r/cimg/node

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 https://app.circleci.com/pipelines/github/andreacab/studiodeville-frontend/11/workflows/1c67441c-8aa0-47b1-be06-d0e4b0a0cbb4/jobs/15.

I then tried the Node 12.16 image instead as recommended, and I also got a red build (see here https://app.circleci.com/pipelines/github/andreacab/studiodeville-frontend/12/workflows/6d502f90-b336-40f9-91ac-6b9a11de6e71/jobs/16). 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:
https://app.circleci.com/pipelines/github/annapamma/sandbox/394/workflows/1d6a2c95-7ab8-45da-a3ff-aeff42170b7f
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 (https://app.circleci.com/pipelines/github/andreacab/studiodeville-frontend/14/workflows/7cb773d6-26c2-4134-84fb-5ef0a7a337c7) and it failed

The second time, this time without the checkout step (https://app.circleci.com/pipelines/github/andreacab/studiodeville-frontend/15/workflows/b7741750-d120-4b00-9bf1-b80bbe34c7a3) 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

Andrea

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?

Thanks!

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 https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored

Hi @andreacab1,

I’m so glad it’s working now!

If you have questions later, you can always submit a support ticket at https://support.circleci.com/ also!

Happy building!

1 Like

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