Search code examples
angulartypescriptdeploymentvercel

Troubles with deploying my angular application to vercel hosting


I wanted to deploy my application to vercel hosting, but after trying for a few hours I am still unsuccsesfull. I am getting an error in vercel logs that says:

Error: Command "npm run build" exited with 1

And there is also one strange line:

Node.js v18.13.0

When I type node -v to my VSCode console or just regular cmd, the version of Node.js is v16.16.0. not the one in vercel logs.

This is the log with an error:

Compiling @angular/material/checkbox : es2015 as esm2015 Compiling @angular/material/grid-list : es2015 as esm2015 Compiling @angular/material/select : es2015 as esm2015 Compiling ngb-modal : es2015 as esm2015 Compiling @angular/material/progress-bar : es2015 as esm2015 node:internal/crypto/hash:71 this[kHandle] = new _Hash(algorithm, xofLen); ^ Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) at BulkUpdateDecorator.hashFactory (/vercel/path0/node_modules/webpack/lib/util/createHash.js:145:18) at BulkUpdateDecorator.update (/vercel/path0/node_modules/webpack/lib/util/createHash.js:46:50) at RawSource.updateHash (/vercel/path0/node_modules/webpack/node_modules/webpack-sources/lib/RawSource.js:77:8) at NormalModule._initBuildHash (/vercel/path0/node_modules/webpack/lib/NormalModule.js:880:17) at handleParseResult (/vercel/path0/node_modules/webpack/lib/NormalModule.js:946:10) at processResult (/vercel/path0/node_modules/webpack/lib/NormalModule.js:755:11) at /vercel/path0/node_modules/webpack/lib/NormalModule.js:819:5 { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.13.0 Error: Command "npm run build" exited with 1 Deployment completed BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1

And these are the build settings:

enter image description here


Solution

  • It seems your local node version is 16.16.0 but node version on Vercel hosing is 18.13.0. In version 18 there can be some changes which cause compile errors. Try defining the same node version in your Vercel hosting settings. I found this useful https://vercel.com/changelog/node-js-version-now-customizable-in-the-project-settings