medic / cht-conf

A command-line interface for configuring Community Health Toolkit applications
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
23 stars 25 forks source link

Error trying to upload a config - ERR_OSSL_EVP_UNSUPPORTED #588

Open tatilepizs opened 9 months ago

tatilepizs commented 9 months ago

Describe the bug I am seeing an error when I try to upload a specific config in my local environment.

This is the error when I try to execute cht --local

INFO Packaging contact-summary
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:130:10)
    at module.exports (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/util/createHash.js:169:42)
    at ConcatenatedModule._createIdentifier (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/optimize/ConcatenatedModule.js:563:16)
    at new ConcatenatedModule (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/optimize/ConcatenatedModule.js:445:27)
    at /usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js:250:26
    at SyncBailHook.eval [as call] (eval at create (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:16)
    at SyncBailHook.lazyCompileHook (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/tapable/lib/Hook.js:154:20)
    at /usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/Compilation.js:1351:37
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/tapable/lib/Hook.js:154:20)
    at Compilation.seal (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/Compilation.js:1342:27)
    at /usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/Compiler.js:675:18
    at /usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/webpack/lib/Compilation.js:1261:4
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
    at AsyncSeriesHook.lazyCompileHook (/usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/node_modules/tapable/lib/Hook.js:154:20) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

If I export the NODE_OPTIONS to the following value, the issue is "fixed"

export NODE_OPTIONS=--openssl-legacy-provider

...
INFO Packaging contact-summary
INFO Hash: 7afbd90c137c4f9a8198
Version: webpack 4.47.0
Child
    Hash: 7afbd90c137c4f9a8198
    Time: 2245ms
    Built at: 11/28/2023 12:14:51 PM
                   Asset     Size  Chunks             Chunk Names
    ./contact-summary.js  132 KiB       0  [emitted]  main
    Entrypoint main = ./contact-summary.js
    [0] ./node_modules/underscore/modules/_setup.js 1.78 KiB {0} [built]
    [1] ./node_modules/luxon/build/cjs-browser/luxon.js 248 KiB {0} [built]
    [2] ./node_modules/cht-nootils/src/nootils.js 3.61 KiB {0} [built]
    [3] ./common.js 13.3 KiB {0} [built]
    [4] /usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/src/contact-summary/lib.js 203 bytes {0} [built]
    [5] ./contact-summary.templated.js 13.1 KiB {0} [built]
    [6] ./contact-summary-extra.js 20.5 KiB {0} [built]
    [7] (webpack)/buildin/global.js 472 bytes {0} [built]
    [8] /usr/local/Cellar/node@16/16.20.1_1/lib/node_modules/cht-conf/src/contact-summary/contact-summary-emitter.js 3.41 KiB {0} [built]
    [9] ./node_modules/underscore/modules/index-all.js + 159 modules 81.3 KiB {0} [built]
        | ./node_modules/underscore/modules/index-all.js 809 bytes [built]
        | ./node_modules/underscore/modules/index.js 8.7 KiB [built]
        | ./node_modules/underscore/modules/index-default.js 872 bytes [built]
        | ./node_modules/underscore/modules/restArguments.js 1.1 KiB [built]
        | ./node_modules/underscore/modules/isObject.js 161 bytes [built]
        | ./node_modules/underscore/modules/isNull.js 98 bytes [built]
        | ./node_modules/underscore/modules/isUndefined.js 104 bytes [built]
        | ./node_modules/underscore/modules/isBoolean.js 200 bytes [built]
        | ./node_modules/underscore/modules/isElement.js 118 bytes [built]
        | ./node_modules/underscore/modules/isString.js 78 bytes [built]
        | ./node_modules/underscore/modules/isNumber.js 78 bytes [built]
        | ./node_modules/underscore/modules/isDate.js 76 bytes [built]
        | ./node_modules/underscore/modules/isRegExp.js 78 bytes [built]
        | ./node_modules/underscore/modules/isError.js 77 bytes [built]
        | ./node_modules/underscore/modules/isSymbol.js 78 bytes [built]
        |     + 145 hidden modules
INFO Packaging nools
...

Expected behavior The config should be uploaded without any problem. It is working fine for other people using linux for example.

Logs NA

Screenshots NA

Environment

lorerod commented 9 months ago

Hi @tatilepizs! I was able to load the config in my local cht without exporting the NODE_OPTIONS variable. And without any errors. Environment

I use the Dev environment setup export COUCH_NODE_NAME=nonode@nohost export COUCH_URL=http://medic:password@localhost:5984/medic Couchdb setup Run: npm run build-dev-watch npm run dev-api npm run dev-sentinel Cloned the config repository: git clone https://github.com/medic/config-moh-mali-chw.git Run npm ci inside config-moh-mali-chw directory Run cht --url=http://medic:password@localhost:5988/ After a while i finally got INFO All actions completed. in the logs. And my instance looks like this: image

Let me know if you want to try this together.