TypeError: crypto.hash is not a function
Problem
Describe the bug 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. [code block] Reproduction . Steps to reproduce _No response_ System Info [code block] Used Package Manager pnpm Logs _No response_ Validations - [x] Follow our Code of Conduct - [x] Read the Contributing Guidelines. - [x] Read the docs. - [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. - [x] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead. - [x] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server. - [x] The provided reproduction is a minimal reproducible example of the bug.
Error Output
error when starting dev server:
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: TypeError: crypto.hash is not a function
I encountered the same problem, I had a version 21 of node and when I upgraded to version 22.16.0 I deleted the node_module files, the package-lock.json and I reinstalled the dependencies, it now works without any problem
Trust Score
9 verifications
- 1
I encountered the same problem, I had a version 21 of node and when I upgraded t
I encountered the same problem, I had a version 21 of node and when I upgraded to version 22.16.0 I deleted the node_module files, the package-lock.json and I reinstalled the dependencies, it now works without any problem
Validation
Resolved in vitejs/vite GitHub issue #20287. Community reactions: 144 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep