primevue icon indicating copy to clipboard operation
primevue copied to clipboard

Forms Resolver: yupResolver import error

Open jsodeman opened this issue 1 year ago • 6 comments

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

image

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

jsodeman avatar Nov 03 '24 15:11 jsodeman

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.

mertsincan avatar Nov 04 '24 00:11 mertsincan

The whole file of @primevue/forms/resolvers/* is empty. What does it export...

DynamicLoader avatar Nov 04 '24 08:11 DynamicLoader

It uses @primeuix/forms API. https://www.npmjs.com/package/@primevue/forms?activeTab=code

Did you try our sample stackblitz link?

mertsincan avatar Nov 04 '24 09:11 mertsincan

So similar of the name... Just install it and OK!

DynamicLoader avatar Nov 04 '24 09:11 DynamicLoader

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 image

jsodeman avatar Nov 04 '24 13:11 jsodeman

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'.

jarrednorrisdev avatar Nov 05 '24 08:11 jarrednorrisdev

I've got a simular issue. I can't import any of the resolvers. Bildschirmfoto 2024-11-27 um 10 19 06 Is this a bug or am i missing something?

KarlBoosterBaer avatar Nov 27 '24 09:11 KarlBoosterBaer

I have the same problem! Any workarounds yet?

Bouwplaats avatar Dec 08 '24 00:12 Bouwplaats

I was able to get it working :

  • "primevue": "^4.2.4"
  • "@primevue/forms": "^4.2.4"

image

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

carlsonaaron avatar Dec 10 '24 22:12 carlsonaaron

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 image

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 image

EDIT with workaround

I found after writing the comment a workaround based on an earlier comment.

  1. Install the package behind the form resolvers pnpm i @primeuix/forms
  2. Import directly from primeuix import { zodResolver } from '@primeuix/forms/resolvers/zod'

Issue should be solved

JoeyRoeters avatar Dec 23 '24 14:12 JoeyRoeters

It happens for me when im using Vue 3's Composition API with typescript. Screenshot 2024-12-25 at 14 57 11

mataharax avatar Dec 25 '24 05:12 mataharax

I updated the moduleResolution option in tsconfig.json to bundler and it was solved :

{
  "compilerOptions": {
    "moduleResolution": "bundler",
    ...
}

zhang35 avatar Jan 08 '25 04:01 zhang35

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?

mertsincan avatar Jan 08 '25 09:01 mertsincan

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.

github-actions[bot] avatar Jan 08 '25 09:01 github-actions[bot]

Seguimos con el mismo problema

Image Image

EnriqueGo94 avatar Aug 07 '25 11:08 EnriqueGo94

@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.

EmersonMedina avatar Sep 09 '25 23:09 EmersonMedina

npm i @primeuix/forms resolved

vuongnq9x avatar Sep 22 '25 07:09 vuongnq9x