Npm run gives a digital-envelope-routines:: unsupported error for some samples

Many of the Apryse samples, for example GitHub - PDFTron/webviewer-react-sample: Sample to demonstrate integrating WebViewer into React use npm to run them. If Node 17 or 18 is installed then an error digital-envelope-routines:: unsupported can occur. This is caused because Webpack uses methods basdd on MD4 algorithms which have been moved.

While it is possible to solve this problem by downgrading to Node 16 (either by replacing the installed version of node or using the node version manager nvm), an alternative is to Enable the legacy OpenSSL provider.

The way to do this differs between platforms
Unix-like (Linux, macOS, Git bash, etc.):
export NODE_OPTIONS=–openssl-legacy-provider

On Windows the way to do this differs between Windows Command Prompt and PowerShell.

Windows Command Prompt:
set NODE_OPTIONS=–openssl-legacy-provider

$env:NODE_OPTIONS = “–openssl-legacy-provider”

1 Like