Reputation: 45
My Code:
"use client"
import vine from "@vinejs/vine"; //cause problem
export default function Test() {
return <></>
}
Error:
Failed to compile
node:dns/promises
Module build failed: UnhandledSchemeError: Reading from "node:dns/promises" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
It seems like the module require some server function? any ideas?
Upvotes: 0
Views: 925
Reputation: 36
vineJS is a Node.js based validation library and only works on Node.js server.
As per your code, "use client" directive makes the React component client side and executes on the browser, so importing and running vineJS on the browser is not allowed as it requires Node.js, hence the error.
Alternative solution,
Use zod or validator.js or yup validation libraries which works on both browser and Node.js.
Use client form libraries such as react-hook-form or formik. They have built-in form validation or you extend it by using the above validation libraries.
Upvotes: 1