#Vercel build process fails because it's not using local pnpm monorepo workspace package

4 messages · Page 1 of 1 (latest)

little sage
#

I have a monorepo setup that shares code between a Next.js 13.3 app directory app and another app via a packages/shared workspace which I include via import { LookupOptions, cleanupUrl } from '@doesithaveafeed/shared'; and a "@doesithaveafeed/shared": "workspace:*", dependency.

Locally everything works fine. I can even run the next build process locally without a problem. However, when I deploy to Vercel, it looks like the build process there is trying to resolve @doesithaveafeed/shared as a package on a registry rather than use the local one in the monorepo and it fails.

Detected Next.js version: 13.3.0
Running "pnpm run build"
> @doesithaveafeed/[email protected] build /vercel/path0/apps/site
> next build
warn  - You have enabled experimental feature (appDir) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
info  - Creating an optimized production build...
Failed to compile.
./src/hooks/useFeedCheck.ts
Module not found: Can't resolve '@doesithaveafeed/shared'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./src/components/LookupForm.tsx
./src/app/api/check/route.ts
Module not found: Can't resolve '@doesithaveafeed/shared'
https://nextjs.org/docs/messages/module-not-found
> Build failed because of webpack errors
 ELIFECYCLE  Command failed with exit code 1.
Error: Command "pnpm run build" exited with 1
BUILD_UTILS_SPAWN_1: Command "pnpm run build" exited with 1

How would I go about telling it to use the local workspace?

I have the Root Directory set up as apps/site and 'Include source files outside of the Root Directory in the Build Step.' is selected too.

Code here: https://github.com/jschuur/doesithaveafeed.com/tree/main/apps/site

GitHub

Find out if or when a website has an RSS (or Atom) syndication feed. - doesithaveafeed.com/apps/site at main · jschuur/doesithaveafeed.com

#

Well, getting rid of the root directory and making the build command pnpm -F @doesithaveafeed/site build seems to have gotten over that problem, but now I get Warning: Could not identify Next.js version, ensure it is defined as a project dependency.

.../[email protected]/node_modules/aws-crt install$ node ./scripts/install.js
.../[email protected]/node_modules/aws-crt install: The binding already exists, skip rebuilding. To rebuild the native addon, please run install.js with `--rebuild`
.../[email protected]/node_modules/aws-crt install: Done
.../[email protected]/node_modules/esbuild postinstall$ node install.js
.../[email protected]/node_modules/esbuild postinstall$ node install.js
.../[email protected]/node_modules/esbuild postinstall: Done
.../[email protected]/node_modules/esbuild postinstall: Done
devDependencies:
+ @types/lodash 4.14.192
+ @types/node 18.15.11
+ @types/pluralize 0.0.29
+ @types/react 18.0.31
+ @types/react-dom 18.0.11
+ typescript 5.0.3
Done in 42.7s
Warning: Could not identify Next.js version, ensure it is defined as a project dependency.
Error: No Next.js version could be detected in your project. Make sure `"next"` is installed in "dependencies" or "devDependencies"
NEXT_NO_VERSION: No Next.js version could be detected in your project. Make sure `"next"` is installed in "dependencies" or "devDependencies"
little sage
#

Well, I ended up solving this once I realised that by setting a root directory, my build command needed to step out of that root directory.

So now my build command is cd ../.. && pnpm -F @doesithaveafeed/shared build && pnpm -F @doesithaveafeed/site build (will clean this part up with turbo) and the Root Directory setting is apps/site

Didn't seem to work with no Root Directory, not stepping out of the cwd in the build command and using an outputDirectory of apps/site/.next though.

So I have a solution... let's see if turning this into a turborepo helps.