Last updated on 3rd November 2026

Using Yarn 4 in the Build Pipeline

In order to be able to use Yarn 4 to build your node projects, you will need to add the following commands to your build pipeline:

source /opt/nvm/nvm.sh
nvm install 18
nvm use 18

corepack enable
corepack prepare yarn@4.8.1 --activate
yarn --version

Note: DeployHQ build servers come with NVM (Node Version Manager) 0.40.3 pre-installed, so you can directly source it from /opt/nvm/nvm.sh without needing to install it first.

Note: Node.js 25 and later no longer bundle Corepack, so DeployHQ installs it on the Node 25 and 26 build environments. The corepack enable and corepack prepare commands above work on those versions too.

What's new in Yarn 4?

  • Enhanced Plug'n'Play (PnP): It heavily leverages PnP, reducing dependency size and speeding up installations.
  • Stronger Security: It includes features like "Hardened Mode" to protect against supply chain attacks.
  • Corepack Integration: It emphasizes Corepack for consistent package manager versions.
  • Improved Performance: It has performance optimizations, like a new package metadata cache.
  • Modernizing Yarn: Requires Node.js 18+ to leverage newer javaScript features.

Happy deploying!