
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe error you're seeing is a classic dependency installation issue in a monorepo setup. The key messages are:
sh: 1: next: not found - Next.js CLI isn't availablenpm WARN Local package.json exists, but node_modules missing, did you mean to install?This is happening because your Lerna monorepo isn't installing dependencies properly before the build runs. Here's how to fix it:
Update your Netlify build settings:
Change your build command in Netlify (Settings → Build & Deploy → Build settings) from:
npm run build
to:
npm install && npm run build
Or if you're using Lerna's bootstrap:
npm install && npx lerna bootstrap && npm run build
Set the correct base directory if your Next.js app is in a subdirectory. Based on your error, it looks like it's in /web, so set:
web/outFor monorepo builds with Lerna, you might need a more specific approach:
package.json has all workspace packages definednpx lerna bootstrap --hoist to hoist common dependenciesnpm ci && npx lerna bootstrap && npm run buildNote about next export: This command is deprecated in newer Next.js versions. If you're updating your Next.js version, you should use output: 'export' in your next.config.js instead and just run next build.
Quick test locally: Before pushing, try running these commands in sequence locally to ensure they work:
rm -rf node_modules
npm install
npx lerna bootstrap
npm run buildThe root cause is that Netlify is trying to run your build script before dependencies are installed in your monorepo structure. Adding the install step to your build command should resolve this.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store