Node.js error message: digital envelope routines::unsupported (0308010C)

Preface

Often an error occurs when compiling the Shopware Storefront (./bin/build-storefront.sh): digital envelope routines::unsupported. This is caused by a problem in the OpenSSL library in Node.js. This help center article shows you how to fix the problem.



Error message

node:internal/crypto/hash:68
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:68:19)
    at Object.createHash (node:crypto:138:10)
    at module.exports



Troubleshooting

To correct the error, an addition is required in ~/.bash_profile, which supplements the legacy versions of OpenSSL. The file .bash_profile can be found here in the user's home directory.


Add the option here:

export NODE_OPTIONS=--openssl-legacy-provider


To correctly apply the above customization in the ~/.bash_profile file, execute the following command once:

source ~/.bash_profile