Fixed Node ‘ERR_OSSL_EVP_UNSUPPORTED (0308010C:digital envelope routines::unsupported)

When I ran command dotnet publish to build ASP.NET Core 6 + SPA. I got an Error

Error : error : 0308010C:digital envelope routines::unsupported [C:\Users\invest\.jenkins\workspace\INVEST_NET6\
Web\ds.Invest.WebAPI\Wmsl.Invest.WebApi.csproj]
      at new Hash (node:internal/crypto/hash:71:19)
      at Object.createHash (node:crypto:133:10)
      at module.exports (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_mo
  dules\webpack\lib\util\createHash.js:135:53)
      at NormalModule._initBuildHash (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\webpack\lib\NormalModule.js:417:16)
      at handleParseError (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\webpack\lib\NormalModule.js:471:10)
      at C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\webpack\lib\NormalModule.js:503:5
      at C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\webpack\li
  b\NormalModule.js:358:12
      at C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\loader-runner\lib\LoaderRunner.js:373:3
      at iterateNormalLoaders (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
      at iterateNormalLoaders (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\n
  ode_modules\loader-runner\lib\LoaderRunner.js:221:10)
      at C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_modules\loader-run
  ner\lib\LoaderRunner.js:236:3
      at context.callback (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_
  modules\loader-runner\lib\LoaderRunner.js:111:13)
      at Object.loader (C:\Users\invest\.jenkins\workspace\INVEST_NET6\Web\ds.Invest.WebAPI\ClientApp\node_mod
  ules\css-loader\dist\index.js:183:3) {
    opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
    library: 'digital envelope routines',
    reason: 'unsupported',
    code: 'ERR_OSSL_EVP_UNSUPPORTED'
  }

  Node.js v18.12.1
Cause
Solution

Workaround

  • Windows
//Command Line 
set NODE_OPTIONS=--openssl-legacy-provider

//Powershell
$env:NODE_OPTIONS = "--openssl-legacy-provider"
  • Linux
export NODE_OPTIONS=--openssl-legacy-provider

Permanent

NOTE: if you cannot update node.js due to business / constraint / risk. you can use NVM (Node Version Manager) to switch between node.js version.

Reference

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.