Skip to content

chore: update package.json with engines node requirement #20319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Michael-Choi
Copy link

@Michael-Choi Michael-Choi commented Jun 28, 2025

Ran into

error when starting dev server:
TypeError: crypto.hash is not a function
    at getHash (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:2834:21)
    at getLockfileHash (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:11716:9)
    at getDepHash (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:11719:23)
    at initDepsOptimizerMetadata (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:11180:53)
    at createDepsOptimizer (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:34593:17)
    at new DevEnvironment (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:35357:109)
    at Object.defaultCreateClientDevEnvironment [as createEnvironment] (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:35776:9)
    at _createServer (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:28359:132)
    at async CAC.<anonymous> (file:///home/michael/projects/portfolio2.0/node_modules/.pnpm/vite@7.0.0/node_modules/vite/dist/node/cli.js:573:18)
 ELIFECYCLE  Command failed with exit code 1.

When running pnpm run dev with a new vite react project with v7, it requires node
Node.js v20.19.0+
Node.js v22.12.0+

Added engines for a clearer error message

p dev    
 WARN  Unsupported engine: wanted: {"node":"^20.19.0 || >=22.12.0"} (current: {"node":"v20.7.0","pnpm":"9.4.0"})

Description

#20287

@Michael-Choi Michael-Choi changed the title Update package.json with engines node requirement chore: Update package.json with engines node requirement Jun 28, 2025
@Michael-Choi Michael-Choi changed the title chore: Update package.json with engines node requirement chore: update package.json with engines node requirement Jun 28, 2025
@bluwy
Copy link
Member

bluwy commented Jul 2, 2025

The engines doesn't need to be specified in template's package.json. It's already specified in Vite's package.json, which package managers should already pick up and warn about it.

@btea
Copy link
Collaborator

btea commented Jul 10, 2025

I think we can consider synchronizing the engine version information in the template.

For example, I initialized a project in the node18 environment through the pnpm create vite command. I did not receive any warning messages until the dependencies were installed. Only when it was actually started did I see vite throw an error.

The default vite version in our create-vite repository is 7.0.3. Therefore, after initializing the project, we explicitly specify the node version required by vite to tell users the reason for the error.

Refer to #20287, when vite7 was first released, many users mentioned similar issues.

@Michael-Choi
Copy link
Author

if there's anything I can do to help, would love to hop in and give it a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants