Netlify build works on one machine, build fails on the other

I’ve got a weird one. Exact same repo, exactly at the same commit — build works on one machine, but fails on the other related issue is a netlify function I have to integrate with sendgrid.

I get a peculiar error, consistently on the machine where I run netlify build. I can definitely see @sendgrid/mail in my node_modules.

In any case, on a separate machine (also MacOS), netlify build runs fine, no errors.

As it is, the site works fine when deployed.

Where do I even start?

(build.command completed in 38.4s)
Creating function for Netlify Emails integration

Functions bundling

Packaging Functions from .netlify/functions-internal directory:
 - emails/index.js

Packaging Functions from netlify/functions directory:
 - sendgrid/index.ts

✘ [ERROR] Could not resolve "@sendgrid/mail"

      1 │ const sendgridMail = require("@sendgrid/mail");
        ╵                              ~~~~~~~~~~~~~~~~

  The Yarn Plug'n'Play manifest forbids importing "@sendgrid/mail" here because it's not listed as a
  dependency of this package:

      11716 │         "packageDependencies": [\
            ╵                                ~~

  You can mark the path "@sendgrid/mail" as external to exclude it from the bundle, which will
  remove this error and leave the unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

Dependencies installation error

  Error message
  A Netlify Function is using "@sendgrid/mail" but that dependency has not been installed yet.

  By default, dependencies inside a Netlify Function's "package.json" are not automatically installed.
  There are several ways to fix this problem:
    - Removing your Function's "package.json" and adding the dependencies to the project's top-level "package.json" instead. This is the fastest and safest solution.
    - Running "npm install" or "yarn" inside your Netlify Function in your build command.
    - Adding the following plugin to your "netlify.toml":

  package = "@netlify/plugin-functions-install-core"

  Build failed with 1 error:
  netlify/functions/sendgrid/index.ts:1:29: ERROR: Could not resolve "@sendgrid/mail"

  Resolved config
    command: npm run build
    commandOrigin: ui
    publish: /Users/julian/Code/nfl-backoffice/dist
    publishOrigin: ui
        - ./emails/**
  functionsDirectory: /Users/julian/Code/nfl-backoffice/netlify/functions
    - for: /*
        Access-Control-Allow-Origin: '*'
  headersOrigin: config
    - inputs: {}
      origin: config
      package: '@netlify/plugin-emails'

Is everything else the same on the two machines? Are the version of the operating system, Node.js, npm, yarn, netlify-cli, packages, etc. the same on both machines?