-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Module '".../node_modules/zod/index"' has no default export. import type z from 'zod'; #1032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Tree-shaking shouldn't matter here as we're using the I'm not sure why you're seeing a type error though, can you share your package.json, tsconfig etc? |
Of course! {
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"lib": ["es2020", "dom"],
"allowJs": false,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"removeComments": true,
"forceConsistentCasingInFileNames": true,
"downlevelIteration": true,
"strict": true,
"moduleResolution": "node",
"paths": {},
"typeRoots": ["node_modules/@types"],
"types": ["node"],
"allowSyntheticDefaultImports": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"incremental": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"noFallthroughCasesInSwitch": true,
"preserveSymlinks": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": ["node_modules"]
} tsconfig {
"extends": "../../tsconfig.json",
"ts-node": {
"swc": true,
"transpileOnly": true
},
"compilerOptions": {
"declaration": false,
"declarationMap": false,
"allowJs": true,
"checkJs": false,
"outDir": "./dist",
"baseUrl": "./",
"types": ["node", "jest"],
"paths": {
"~api": ["src/app/api"]
}
},
"include": [
"src/**/*.ts",
"src/**/*.js",
"tsconfig.json",
"jest.config.ts",
".eslintrc.js"
]
} package.json {
"name": "our-project",
"version": "1.0.0",
"description": "Awesome project",
"main": "dist/src/index.js",
"scripts": {},
"author": "me",
"license": "ISC",
"dependencies": {
// other libraries
"openai": "^4.56.0",
"zod": "^3.23.8"
},
"devDependencies": {
// other libraries
},
"repository": {
"type": "git",
"url": "url-that-leads-somewhere"
}
} |
We're also getting this error in our Typescript project. tsconfig.json: {
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "out",
"sourceMap": true,
"strict": true,
"target": "es2018",
"allowJs": true,
"strictNullChecks": true,
"resolveJsonModule": true
},
"compileOnSave": true,
"include": ["src"]
} package.json {
"name": "project",
"version": "1.0.0",
"main": "out/src/index.js",
"license": "UNLICENSED",
"openai": "^4.57.1",
"zod": "^3.23.8"
// plus way too many other dependencies...
},
"private": true,
"devDependencies": {
// ...
},
"engines": {
"node": "18"
}
} |
I haven't had a chance to test out the provided reproduction yet, would you be able to edit the installed package to verify if just importing the symbols needed fixes the issue? |
@RobertCraigie yes, I did it yesterday and it solved the error when importing the needed symbols import type { infer as _infer, ZodType } from 'zod'; I guess the problem is that zod library does not export a default ( import type * as z from 'zod'; |
Great thank you! Will have a fix out later today. |
thank you 👍 |
This should be fixed in |
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
I am programming an assistant using the openai library but when trying to build my code it gives the following error.
Shouldn't it be better to import only the necessary types from zod instead of all types?
This way, it would benfit tree-shaking as we are only importing what we need.
To Reproduce
Code snippets
No response
OS
Ubuntu
Node version
v20.15.0
Library version
openai v4.56.0
The text was updated successfully, but these errors were encountered: