Description
Describe the bug
Trying to import { z } from 'genkit'
on the server results in:
9:06:01 AM [vite] (ssr) Error when evaluating SSR module ./server.mjs: Cannot read properties of undefined (reading 'object')
at eval (D:\GitHub\test-genkit\src\app\output-schema\menu-item-schema.ts:3:33)
I have a repo here that can be used to reproduce: https://github.com/markgoho/test-genkit
To Reproduce
Check out repo, npm install
Failure: in menu-item-schema.ts
and genkit.ts
replace z
import statements with import { z } from 'genkit
;`
Run: npx genkit start -- ng serve
Access localhost:4200 and see error both in browser (short error) and in terminal:
9:06:01 AM [vite] (ssr) Error when evaluating SSR module ./server.mjs: Cannot read properties of undefined (reading 'object')
at eval (D:\GitHub\test-genkit\src\app\output-schema\menu-item-schema.ts:3:33)
at async ESModulesEvaluator.runInlinedModule (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1049:5)
at async SSRCompatModuleRunner.directRequest (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1271:61)
at async SSRCompatModuleRunner.directRequest (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-DrOo5SEf.js:30915:23)
at async SSRCompatModuleRunner.cachedRequest (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1167:76)
at async SSRCompatModuleRunner.import (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1104:12)
at async instantiateModule (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-DrOo5SEf.js:30872:12)
TypeError: Cannot read properties of undefined (reading 'object')
at eval (D:\GitHub\test-genkit\src\app\output-schema\menu-item-schema.ts:3:33)
at async ESModulesEvaluator.runInlinedModule (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1049:5)
at async SSRCompatModuleRunner.directRequest (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1271:61)
at async SSRCompatModuleRunner.directRequest (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-DrOo5SEf.js:30915:23)
at async SSRCompatModuleRunner.cachedRequest (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1167:76)
at async SSRCompatModuleRunner.import (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/module-runner.js:1104:12)
at async instantiateModule (file:///D:/GitHub/test-genkit/node_modules/@angular/build/node_modules/vite/dist/node/chunks/dep-DrOo5SEf.js:30872:12)
If you revert changes to import { z } from '@genkit-ai/core';
and restart the run command completely this now works as expected.
Expected behavior
Importing z from recommended source should work.
Screenshots
If applicable, add screenshots to help explain your problem.
Runtime (please complete the following information):
- OS: [e.g. Linux, MacOS] Windows 11
- Version [e.g. 22]
** Node version
- 22.14
Additional context
This obviously could be an issue with Angular, vite, ssr, etc. However, if this is a known issue, we might want to recommend the import { z } from '@genkit-ai/core';
path if users are using Angular SSR to avoid this issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status