Question

Turborepo deployment failing due to packagemanager

I’m a using a turporepo setup which contains two apps:

  • apps/cms (Strapi CMS with a PG DB)
  • apps/web (Astro WebApp)

Every time we try to deploy them, we are getting an error associated with yarn as the node buildpack uses yarn 1.22.22 by default, it suggests we need to run corepack enable which we have tried to trigger by adding it within the build commands but still does not work.

How could I fix this issue?

Thanks in advance

[34m › configuring custom build command to be run at the end of the build:
2024-05-19T09:58:00.251744396Z    │ cd apps/cms
2024-05-19T09:58:00.251758488Z    │ corepack enable
2024-05-19T09:58:00.252275686Z    │ yarn build
2024-05-19T09:58:00.252287756Z 
2024-05-19T09:58:00.319269293Z ╭──────────── buildpack detection ───────────╼
2024-05-19T09:58:00.335528638Z │  › using Ubuntu 22.04 stack
2024-05-19T09:58:00.937937641Z │ Detected the following buildpacks suitable to build your app:
2024-05-19T09:58:00.937967914Z │ 
2024-05-19T09:58:00.937971888Z │    heroku/nodejs-engine   v1.5.3  
2024-05-19T09:58:00.937975398Z │    digitalocean/node      v0.4.0  (Node.js)
2024-05-19T09:58:00.937978588Z │    digitalocean/procfile  v0.0.4  (Procfile)
2024-05-19T09:58:00.937982291Z │    digitalocean/custom    v0.1.2  (Custom Build Command)
2024-05-19T09:58:00.937984310Z │ 
2024-05-19T09:58:00.937986881Z │ For documentation on the buildpacks used to build your app, please see:
2024-05-19T09:58:00.937988833Z │ 
2024-05-19T09:58:00.937992111Z │    Node.js  v0.4.0  https://do.co/apps-buildpack-node
2024-05-19T09:58:00.941245295Z ╰─────────────────────────────────────────────╼
2024-05-19T09:58:00.941272560Z 
2024-05-19T09:58:00.943913257Z ╭──────────── app build ───────────╼
2024-05-19T09:58:00.971002513Z │ [INFO] Node.js Buildpack
2024-05-19T09:58:00.973743572Z │ [INFO] Setting NODE_ENV to production
2024-05-19T09:58:00.974019490Z │ [INFO] Installing toolbox
2024-05-19T09:58:00.975341133Z │ [INFO] - yj
2024-05-19T09:58:01.365317427Z │ 
2024-05-19T09:58:01.365340654Z │ [Installing Node]
2024-05-19T09:58:01.365343219Z │ [INFO] Getting Node version
2024-05-19T09:58:01.390950726Z │ [INFO] Resolving Node version
2024-05-19T09:58:01.674693837Z │ [INFO] Downloading and extracting Node v20.13.1
2024-05-19T09:58:03.095521508Z │ 
2024-05-19T09:58:03.095565107Z │ [Parsing package.json]
2024-05-19T09:58:03.095568911Z │ [INFO] Parsing package.json
2024-05-19T09:58:03.367251774Z │ 
2024-05-19T09:58:03.367296776Z │ [Installing yarn]
2024-05-19T09:58:03.368738358Z │ [INFO] Installing yarn@1.22.22
2024-05-19T09:58:03.554724361Z │ [INFO] No file to start server
2024-05-19T09:58:03.554761122Z │ [INFO] either use 'docker run' to start container or add index.js or server.js
2024-05-19T09:58:03.572030534Z │ Project contains yarn.lock, using yarn
2024-05-19T09:58:03.577958880Z │ Installing node_modules using yarn (from yarn.lock)
2024-05-19T09:58:04.029299223Z │ Running yarn install
2024-05-19T09:58:04.029609271Z │ 
2024-05-19T09:58:04.203621219Z │ error This project's package.json defines "packageManager": "yarn@4.2.2". However the current global version of Yarn is 1.22.22.
2024-05-19T09:58:04.204084580Z │ 
2024-05-19T09:58:04.204112465Z │ Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
2024-05-19T09:58:04.204119553Z │ Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.
2024-05-19T09:58:04.214014960Z │ 
2024-05-19T09:58:04.214331576Z │ unable to invoke layer creator
2024-05-19T09:58:04.214342045Z │ installing node_modules: exit status 1
2024-05-19T09:58:04.215300753Z │ ERROR: failed to build: exit status 1
2024-05-19T09:58:04.360091142Z │ 
2024-05-19T09:58:04.363468533Z │ 
2024-05-19T09:58:04.363772947Z │ For documentation on the buildpacks used to build your app, please see:
2024-05-19T09:58:04.363779161Z │ 
2024-05-19T09:58:04.363783739Z │    Node.js  v0.4.0  https://do.co/apps-buildpack-node
2024-05-19T09:58:04.363974840Z │ 
2024-05-19T09:58:04.373304981Z │  ✘ build failed

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 19, 2024
Accepted Answer

Hi there,

You can customize the Yarn version used by specifying the version in the engines section of your package.json:

{
  "engines": {
    "yarn": "^0.14.0"
  }
}

https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/

As far as I can see the latest version of Yarn is actually 1.22.22:

https://github.com/yarnpkg/yarn/releases

Have you tried changing the version of yarn in your packageManager definition to the latest one to see if it helps?

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.