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

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

2 Likes

Will the webviewer be available out of the box for Node 18 (without having to change NODE_OPTIONS)? The documentation states that it can support Node.js versions 8 - 18.

Thanks.

1 Like

WebViewer isn’t tied to a specific version of Node, but this specific issue (which I believe is to do with WebPack which is used for apps created with ‘create-react-app’) is not a WebViewer problem as such.
I found that creating a new app using Vite solved this issue see https://www.youtube.com/watch?v=i-1rhs6oPgs

1 Like

Thank you for your info, but the youtube link seems to be outdated…

1 Like

Try now. https://www.youtube.com/watch?v=i-1rhs6oPgs

1 Like