-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Module '"zod"' has no exported member 'z'.ts #3739
Comments
Can you provide |
{
"compilerOptions": {
/* Base Options: */
"esModuleInterop": true,
"skipLibCheck": true,
"target": "ESNext",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
/* Strictness */
"strict": true,
"noUncheckedIndexedAccess": true,
"checkJs": true,
/* Bundled projects */
"lib": ["dom", "dom.iterable", "ESNext"],
"noEmit": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "preserve",
"plugins": [{ "name": "next" }],
"incremental": true,
/* Path Aliases */
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
},
"types": ["cypress"]
},
"include": [
".eslintrc.cjs",
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.js",
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
} |
I got the same error |
Can you try these settings? { "compilerOptions": { "target": "ESNext", "module": "ESNext", "allowImportingTsExtensions": true, "moduleResolution": "Bundler", "noEmit": true, "esModuleInterop": true, "strict": true } } |
I am getting the same error from many days in the vs code. |
when did you start getting it?- JacobOn Sep 12, 2024, at 09:03, Taksh Chanana ***@***.***> wrote:
I am getting the same error from many days in the vs code.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
same |
This fixes it for me: in import typescriptEslint from "@typescript-eslint/eslint-plugin";
import drizzle from "eslint-plugin-drizzle";
import zod from "eslint-plugin-zod";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [...compat.extends(
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
), {
plugins: {
"@typescript-eslint": typescriptEslint,
drizzle,
zod,
},
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: "script",
parserOptions: {
project: true,
},
},
rules: {
"zod/prefer-enum": 2,
"zod/require-strict": 2,
"@typescript-eslint/array-type": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@next/next/no-duplicate-head": "off",
"import/no-anonymous-default-export": "off",
"@typescript-eslint/consistent-type-imports": ["warn", {
prefer: "type-imports",
fixStyle: "inline-type-imports",
}],
"@typescript-eslint/no-unused-vars": ["warn", {
argsIgnorePattern: "^_",
}],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-misused-promises": ["error", {
checksVoidReturn: {
attributes: false,
},
}],
"@typescript-eslint/no-empty-object-type": "off",
"drizzle/enforce-delete-with-where": ["error", {
drizzleObjectName: ["db", "ctx.db"],
}],
"drizzle/enforce-update-with-where": ["error", {
drizzleObjectName: ["db", "ctx.db"],
}],
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-argument": "off",
},
}]; Then install the dependencies: bun add @eslint/js @eslint/eslintrc @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-import eslint-plugin-drizzle eslint-plugin-zod For reference, here's my {
"name": "aii",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"build": "next build",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio",
"db:seed": "bun run src/server/db/seed.ts",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
},
"dependencies": {
"@auth/drizzle-adapter": "^1.1.0",
"@fullcalendar/daygrid": "^6.1.15",
"@fullcalendar/interaction": "^6.1.15",
"@fullcalendar/react": "^6.1.15",
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-collapsible": "^1.1.0",
"@radix-ui/react-context-menu": "^2.2.1",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-hover-card": "^1.1.1",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-menubar": "^1.1.1",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slider": "^1.2.0",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0",
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@sendgrid/mail": "^8.1.3",
"@t3-oss/env-nextjs": "^0.10.1",
"@tanstack/react-query": "^5.50.0",
"@trpc/client": "^11.0.0-rc.446",
"@trpc/next": "^11.0.0-rc.446",
"@trpc/react-query": "^11.0.0-rc.446",
"@trpc/server": "^11.0.0-rc.446",
"bcrypt": "^5.1.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"drizzle-orm": "^0.33.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.36.1",
"geist": "^1.3.0",
"lucide-react": "^0.441.0",
"next": "^14.2.4",
"next-auth": "^4.24.7",
"node-cron": "^3.0.3",
"nodemailer": "^6.9.15",
"postgres": "^3.4.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.0",
"superjson": "^2.2.1",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.10.0",
"@types/bcrypt": "^5.0.2",
"@types/eslint": "^8.56.10",
"@types/node": "^20.14.10",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
"drizzle-kit": "^0.24.0",
"eslint": "^9.10.0",
"eslint-config-next": "^14.2.4",
"eslint-plugin-drizzle": "^0.2.3",
"eslint-plugin-zod": "^1.4.0",
"postcss": "^8.4.39",
"prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5",
"tailwindcss": "^3.4.3",
"typescript": "^5.5.3"
},
"ct3aMetadata": {
"initVersion": "7.37.0"
}
} |
Okay so for those of us who don't have any linting rules and have this stupid error, what the heck is it |
yeah linting configuration didn’t actually fix it for me either- JacobOn Sep 24, 2024, at 23:13, ZachHandley ***@***.***> wrote:
Okay so for those of us who don't have any linting rules and have this stupid error, what the heck is it
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@colinhacks can you please fix this or look at this, something got effed ❯ bun install
bun install v1.1.30-canary.34 (17d719fa)
+ [email protected]
+ @astrojs/[email protected]
+ @astrojs/[email protected]
+ @astrojs/[email protected]
+ @astrojs/[email protected]
+ @astrojs/[email protected]
+ @astrojs/[email protected]
+ @directus/[email protected]
+ @iconify/[email protected]
+ @inox-tools/[email protected]
+ @nanostores/[email protected]
+ @nanostores/[email protected]
+ @vueuse/[email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
865 packages installed [164.71s] okay great, so it's installed right? and I can use it right? okay............................................. idk what the hell to do here. No package manager properly resolves it and it's broken now on multiple projects. |
i should clarify that this is not a eslint error. because even if i get eslint to shut up next build still fails |
^ correct. Something got effed. |
I have the same issue with Typescript 5.6, but it works fine with Typescript 5.5. I suspect the problem is related to this change (related Typescript pull request). This change was already in the [email protected] prerelease, and I'm also encountering the issue when using this version. |
I fixed above issue by putting the following inside the tsconfig.json for your front end project NOT Amplify file:
|
|
careful with the sudo rm- JacobOn Oct 9, 2024, at 15:52, Taksh Chanana ***@***.***> wrote:
Add this to your package.json dependency (^ is the problem)
"zod": "3.22.4"
Remove node_modules(sudo rm -rf node_modules)
Re-install npm modules (npm i)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
^ is not the problem. ^ merely allows to get the newest 3.x.x version out there. The real problem is the specific version ^3 gets you and since I just installed zod in my new project my version looks like this But sure, I installed v3.22.4 and it worked, so then I kept upgrading zod until it broke. v3.23.7 works and v3.23.8 doesnt. Also, v3.23.8 works with commonjs. It's just the ESM part that's broken. |
any update on the issue ? using pnpm instead of bun seems to resolve the issue. |
hmm thank u ill stick with pnpm then- JacobOn Nov 12, 2024, at 03:22, catinrage ***@***.***> wrote:
any update on the issue ? using pnpm instead of bun seems to resolve the issue.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Rolling back from [email protected] to [email protected] fixed the compilation error on my side
|
I fixed it with "allowSyntheticDefaultImports" in tsconfig.json
|
confirmed 3.23.7 works |
Solved this issue (TS2305) by changing |
I get this error when my linter runs over the bunx create-t3-app starting repo. I also get this linting error when i install zod separately into a empty repo. The code runs fine tho. I don't know if I'm missing type deps or maybe the package has changed and all the tutorials telling me to
import {z} from 'zod'
are outdated now. How can i fix this error?zod version: ^3.23.3
bun version: 1.1.17
node version: v20.12.2
package.json
:The text was updated successfully, but these errors were encountered: