error during build: [vite:css] [postcss] crypto.hash is not a function

brennant123
HOBBY

13 days ago

Forgive me if this is obvious , as I am fairly new to railway.

I recently have been working on my resume website. I made a few minor changes and suddenly my deploy is failing with this error. I did not change anything that should have broken my app.

Edit: the issue was that railway was using the wrong node version. I have since fixed it and it is no working.

Solved$10 Bounty

2 Replies

13 days ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 13 days ago


13 days ago

Try:

Add a package.json field to lock your Node version:

"engines": { 
     "node": "20" 
}

Or be more specific if needed:

"engines": { 
    "node": "20.11.1"
}

You can also set the version with NIXPACKS_NODE_VERSION=20.11.1 as an environment variable in Railway.


aj224
FREE

12 days ago

crypto.hash is only available in Node.js v16.17.0+ (or better, v18+).

Older versions like v14 or early v16 don't have this method.
In your package.json set engines for latest nodejs version
"engines": {

"node": ">=18.0.0"

}

And if you want to update in Railway only

  • Go to your project settings

  • Find the Environment or Build Settings

  • Set the Node version to 18 or higher


Status changed to Solved brody 11 days ago