After building fine many times suddenly node is unable to find the validator library I've been using just fine for months, zod. I first got this error:
error during build: [vite]: Rollup failed to resolve import "zod" from "/vercel/path0/src/lib/formSchemas/schemas.ts". This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to
build.rollupOptions.external... Error: Command "npm run build" exited with 1
So now my vite.config.ts looks like this:
import { sveltekit } from '@sveltejs/kit/vite';import { defineConfig } from 'vite';
export default defineConfig({ plugins: [sveltekit()], build:{ rollupOptions:{ external: [ 'zod' ] } }});And now I get this error
node:internal/event_target:1105 process.nextTick(() => { throw err; }); ^ Error: Cannot find package '/vercel/path0/node_modules/zod/index.js' imported from /vercel/path0/.svelte-kit/output/server/chunks/schemas.js
My app builds fine on my machine. After this error started happening I updated all my packages and that hasn't fixed or changed the issue. I had not changed anything to do with importing zod when the error appeared. My current production page uses the exact same library and imports with no issue.