Next.js build Works Locally but Fails on Netlify (Static Page Generation)


My netlify site name is:

I have a mono repo with a shared UI package. The shared package has react-hook-form controlled Input components. My site’s Login page uses the input components. My netlify build is throwing the following errors on static page generation:

11:27:42 PM: aemiko: TypeError: Cannot read properties of null (reading 'formState')
11:27:42 PM: aemiko:     at InputRHF (/opt/build/repo/apps/aemiko/build/serverless/pages/login.js:2379:36)

InputRHF are my shared package’s react-hook-form input components.

My netlify.toml file looks like:

  from = "/*"
  to = "/index.html"
  status = 200
  force = false

  publish = "apps/aemiko/build"
  command = "npm i -gs yarn && yarn build:aemiko"

Below is my root package.json file (I’m using yarn).

  "name": "verde-monorepo",
  "private": true,
  "scripts": {
    "codegen": "lerna --scope='{abp,aemiko}' run codegen",
    "add:all": "lerna add",
    "add:abp": "lerna add $1 --scope=abp",
    "add:ui": "lerna add $1 --scope=@aemiko/ui",
    "add:web": "lerna add $1 --scope=aemiko",
    "bootstrap": "lerna bootstrap",
    "prebuild": "lerna bootstrap",
    "start:abp:dev": "lerna --scope=abp run start:dev --stream",
    "start:abp": "yarn bootstrap && lerna --scope=abp run start --stream",
    "build:abp": "yarn bootstrap && lerna --scope=abp run build --stream",
    "start:aemiko:dev": "lerna --scope=aemiko run dev --stream",
    "start:aemiko": "lerna --scope=aemiko run start --stream",
    "build:aemiko": "yarn build:shared && yarn && yarn bootstrap && lerna --scope=aemiko run build --stream",
    "build:shared": "lerna --scope='{@aemiko/ui,@aemiko/utils}' run build --stream",
    "build:shared:dev": "lerna --scope='{@aemiko/ui,@aemiko/utils}' run build:dev --stream"
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.30.0",
    "@typescript-eslint/parser": "^4.30.0",
    "eslint": "^7.32.0",
    "lerna": "^4.0.0",
    "prettier": "^2.3.2",
    "pwa-asset-generator": "^4.3.6",
    "run-s": "^0.0.0",
    "ts-node": "^10.2.1"
  "workspaces": {
    "packages": [
    "nohoist": [

Hi @aemiko

Is there a public repo what we could use to see this error?