Repository navigation
Replies: 6 comments 10 replies
|
Hi, |
|
Yes https://vite.dev/blog/announcing-vite7#node-js-support , 20.19+ or 22.12+ |
|
if you use nmv you can do: nvm install 20.19.3 remove node_modules if any and reinstall them. |
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 functionThis 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.jsReplace 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. |
|
Found a fix for no solution even after updating Node to an accepted version and deleting Run |
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.
All reactions