25

I was trying to build my project on jenkins. The local build is successful but Jenkins build is failing. Any fix for this? I am using primeng module to implement p-organisationchart. I suspect that could be the issue.

versions I am using are:

`"primeicons": "^4.1.0",
 "primeng": "^11.3.0",
 "node" : 14.16.0`

I am working on Angular 8

Arjun C E
  • 382
  • 1
  • 3
  • 9

7 Answers7

46

This is a webpack issue. As a workaround you can add an environment variable to your build task:

export NODE_OPTIONS=--openssl-legacy-provider

See this issue in the webpack project.

You can add the environment variable to your package.json scripts part

{
  "scripts": {
    "build": "export NODE_OPTIONS=--openssl-legacy-provider; ng build"
  }
}

If you are using docker you can add the environment variable to your Docker file before the build

ENV NODE_OPTIONS=--openssl-legacy-provider

I am not familiar with jenkins. If you use bash-like scripts there to build your application you can also add the line to that script.

Note: In windows use set instead of export

HOERNSCHEN
  • 730
  • 1
  • 8
  • 19
14

I was having this very same error, and it was solved by downgrading from Node 17.2 to 16.10

You may also run this in the console before launching ng serve

$ export NODE_OPTIONS=--openssl-legacy-provider 
jdgomezb
  • 151
  • 1
  • 4
1

The accepted answer and workaround overlooks security vulnerabilities in older Node.js version 17, which uses OpenSSL version 3 by default. My organization is requiring upgrade to version 18 of Node.js because of this issue, so to downgrade my version or use legacy OpenSSL is not an option for me.

From below stack trace you can see MD4 hash vulnerability and error and that it occurs in Webpack. So you would think the latest version of Webpack would fix issue.

     Generating browser application bundles (phase: building)...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 module.exports (C:\workspace\ssdweb\src\main\angular\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\workspace\ssdweb\src\main\angular\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (C:\workspace\ssdweb\src\main\angular\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\workspace\ssdweb\src\main\angular\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\workspace\ssdweb\src\main\angular\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\workspace\ssdweb\src\main\angular\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\workspace\ssdweb\src\main\angular\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (C:\workspace\ssdweb\src\main\angular\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at C:\workspace\ssdweb\src\main\angular\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at context.callback (C:\workspace\ssdweb\src\main\angular\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at Object.loader (C:\workspace\ssdweb\src\main\angular\node_modules\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.16.0
lstan
  • 9
  • 3
  • Did you get your issue resolved? – Sugar Bowl May 25 '23 at 17:27
  • 1
    No, not at this time. I thought an install of latest version of webpack would fix it but have too many dependency issues. Went back to older version. Will have to address it in a few weeks, and will try to give update with solution. – lstan May 26 '23 at 19:49
1

I had node version 20 and still having this issue then I removed Angular CLI and installed the latest version and so the problem solved.

Serhat Koroglu
  • 1,263
  • 4
  • 19
  • 41
0

How to solve the digital envelope routines::unsupported in angular

Step to Procedure:

1.Install the old veriosn of node js . Example 16,17. My suggestion to use node js 16 version

2.After install the node js check the version in cmd command node -v.

3.After the checking the version build your Project by using ng build --prod command

Cause of the issue:

update node js version is not supported in older angular version

balaji
  • 1
  • 1
0

The solution that worked for me was downgrading to node version 14. Everything else I tried was not successful.

makwasi Crispus
  • 143
  • 1
  • 8
-1

I got the same error when this was written. My previous node version was the latest (18). What I do to solve this:

  1. go to nodejs website: nodejs.org
  2. search for version of nodejs which has npm version 6.14.8 -> I got nodejs v.14.15.0 -> download
  3. extract your download of nodejs: tar -xf (the-nodejs-file)
  4. edit .bashrc file $ vim ~/.bashrc and save it by :wq
  5. add this line: export PATH="/home/(your-name)/Downloads/node-v14.15.0-linux-x64/bin:$PATH"
  6. restart your terminal
  7. go to your project directory cd (your directory)
  8. run project ng serve

ng serve works!