Replies: 5 comments 6 replies
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Yes https://vite.dev/blog/announcing-vite7#node-js-support , 20.19+ or 22.12+ |
Beta Was this translation helpful? Give feedback.
-
if you use nmv you can do: nvm install 20.19.3 remove node_modules if any and reinstall them. |
Beta Was this translation helpful? Give feedback.
-
Duplicate of #20287 (comment) |
Beta Was this translation helpful? Give feedback.
-
Proposed Fix for crypto.hash is not a function Error in Vite 7.0.0 (#20286)ProblemWhen running npm run dev with Vite 7.0.0, the following error occurs: TypeError: crypto.hash is not a function This happens because the crypto.hash method is only available on Node.js version 20.12.0 or higher (or 21.7.0+), but some users may be running an older Node.js version. Temporary WorkaroundEdit the function getHash() in the file: node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js Replace the direct call to crypto.hash with a fallback function that uses crypto.createHash: import crypto$2 from 'node:crypto';
const hash$1 = (
crypto$2.hash ?? ((algorithm, data, outputEncoding) => crypto$2.createHash(algorithm).update(data).digest(outputEncoding))
);
function getHash(text, length = 8) {
const h = hash$1("sha256", text, "hex").substring(0, length);
if (length <= 64) return h;
return h.padEnd(length, "_");
}
This patch can be automated with a post-install script. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I simply installed a React TypeScript project using pnpm create vite and tried to run it, but encountered the following error. I'm on a Windows environment and using Node.js version v20.9.0. This issue didn't occur before, so it seems to be related to the recent update to Vite version 7.0.
Beta Was this translation helpful? Give feedback.
All reactions