microsoft / onnxruntime-nextjs-template

MIT License
96 stars 22 forks source link

`yarn dev` throws a `digital envelope` error #3

Open kjczarne opened 1 year ago

kjczarne commented 1 year ago

Without any modification to the code distributed in this repo. Steps to reproduce:

  1. yarn
  2. yarn dev

Node.JS v18.12.0

Traceback:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at OriginalSource.updateHash (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack-sources3/index.js:1:10264)
    at NormalModule._initBuildHash (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68468:17)
    at handleParseResult (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68534:10)
    at /home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68628:4
    at processResult (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68343:11)
    at /home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68407:5
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at OriginalSource.updateHash (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack-sources3/index.js:1:10264)
    at NormalModule._initBuildHash (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68468:17)
    at handleParseResult (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68534:10)
    at /home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68628:4
    at processResult (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68343:11)
    at /home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68407:5
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 BulkUpdateDecorator.hashFactory (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at OriginalSource.updateHash (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack-sources3/index.js:1:10264)
    at NormalModule._initBuildHash (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68468:17)
    at handleParseResult (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68534:10)
    at /home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68628:4
    at processResult (/home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68343:11)
    at /home/chris/onnx_demo/node_modules/next/dist/compiled/webpack/bundle5.js:68407:5 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
kjczarne commented 1 year ago

Same issue observed in: https://github.com/microsoft/onnxruntime-web-demo

developer239 commented 1 year ago

@kjczarne I made it work with node v14.17.6 and this package.json

{
  "name": "ort-web-template",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build && next export",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "fs": "0.0.1-security",
    "jimp": "0.16.1",
    "lodash": "4.17.21",
    "ndarray": "1.0.19",
    "ndarray-ops": "1.2.2",
    "next": "11.1.2",
    "onnxruntime-web": "1.9.0",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "node-polyfill-webpack-plugin": "1.1.4",
    "copy-webpack-plugin": "9.0.1",
    "@types/lodash": "4.14.176",
    "@types/react": "17.0.19",
    "eslint": "7.32.0",
    "eslint-config-next": "11.1.0",
    "typescript": "4.4.2"
  }
}
airinterface commented 1 year ago

Before the fix, we can run with below with node v17 and above export NODE_OPTIONS=--openssl-legacy-provider; npm run dev