Skip to content

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

Closed
Michael-Choi wants to merge 1 commit intovitejs:mainfrom
Michael-Choi:patch-1
Closed

chore: update package.json with engines node requirement#20319
Michael-Choi wants to merge 1 commit intovitejs:mainfrom
Michael-Choi:patch-1

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
Contributor

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

@sapphi-red
Copy link
Member

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

This won't show the warning for the users that upgraded Vite 6 -> 7.
Given that there're many people encountering this and the error isn't clear enough for them, I think we need to add a warning like the one in astro.
https://github.com/withastro/astro/blob/aafc4d7f8b3f198ace24a8a7f6cc9298771542da/packages/astro/astro.js#L22-L33

@btea
Copy link
Contributor

btea commented Jul 28, 2025

Looks great. 👍

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.

4 participants