Forms Resolver: yupResolver import error
Describe the bug
Importing the yupResolver results in an error:
"[plugin:vite:import-analysis] Failed to resolve entry for package "@primevue/forms". The package may have incorrect main/module/exports specified in its package.json."
Importing the yupResolver by pointing to the yup sub-folder works, though the IDE shows an error
So it looks like the resolver isn't being passed up to the top level exports from the resolvers library.
Reproducer
https://stackblitz.com/edit/primevue-4-vite-issue-template-6bfxlz?file=src%2FApp.vue
PrimeVue version
4.2.1
Vue version
4.x
Language
ES6
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
import { yupResolver } from '@primevue/forms/resolvers';
Expected behavior
No response
Please don't use import { yupResolver } from '@primevue/forms/resolvers';. You need to import from @primevue/forms/resolvers/yup in 4.2.1. Could you please try it after clearing whole caches?
...The forms library provide built-in resolvers for popular options including Zod, Yup, Joi, Valibot, and Superstruct that can be be imported from @primevue/forms/resolvers/* path.
The whole file of @primevue/forms/resolvers/* is empty. What does it export...
It uses @primeuix/forms API. https://www.npmjs.com/package/@primevue/forms?activeTab=code
Did you try our sample stackblitz link?
So similar of the name... Just install it and OK!
I cleared the IDE caches and deleted node_modules and package-lock.json.
ESLint: yupResolver not found in '@primevue/ forms/ resolvers/ yup'(import/ named)
The stackblitz linked in the docs has a similar error
https://primevue.org/forms/#resolvers
Having the same problem trying to import the zodResolver,
Package Versions:
"@primevue/forms": "^4.2.1",
"@primevue/themes": "^4.2.1",
"primevue": "^4.2.1",
Import Statement:
import { zodResolver } from '@primevue/forms/resolvers/zod';
Error:
Module '"@primevue/forms/resolvers/zod"' has no exported member 'zodResolver'.
I've got a simular issue. I can't import any of the resolvers.
Is this a bug or am i missing something?
I have the same problem! Any workarounds yet?
I was able to get it working :
- "primevue": "^4.2.4"
- "@primevue/forms": "^4.2.4"
As a "trying anything" move, I also cleaned my npm cache with npm cache clean --force. Whether that is what fixed it or not, I'm not sure, but I was getting that "Cannot resolve symbol 'yupResolver'" error beforehand but now it seems to be finding it
Seems like the issue still occurs, even in the latests version of the @primevue/forms package 4.2.5.
It's weird since the import of any resolver is not working
but i'm able to click through on the imports and see that the actual resolver is there and being exported. I'm not sure if the export is right or typescript is messing up something, anyways it seems for now that the resolver functionality will not work
EDIT with workaround
I found after writing the comment a workaround based on an earlier comment.
- Install the package behind the form resolvers
pnpm i @primeuix/forms - Import directly from primeuix
import { zodResolver } from '@primeuix/forms/resolvers/zod'
Issue should be solved
It happens for me when im using Vue 3's Composition API with typescript.
I updated the moduleResolution option in tsconfig.json to bundler and it was solved :
{
"compilerOptions": {
"moduleResolution": "bundler",
...
}
Unfortunately, I couldn't replicate it with v4.2.5. Please try; https://github.com/mertsincan/primevue-ts-example/tree/form
Can you send me a project link after you update my test project according to your config?
We're unable to replicate your issue, if you are able to create a reproducer by using PrimeVue Issue Template or add details please edit this issue. This issue will be closed if no activities in 20 days.
Seguimos con el mismo problema
@EnriqueGo94 Yo probé instalando separadamente yup: npm install yup y con eso ya no salen errores, destacando que no se si es la forma correcta, pero no encontré otra solución.
npm i @primeuix/forms resolved