From 2dc9c5c444b08c1d306e570b5f0795cdd04daa1f Mon Sep 17 00:00:00 2001 From: chenos Date: Fri, 10 Feb 2023 11:16:36 +0800 Subject: [PATCH] fix: error:0308010C:digital envelope routines::unsupported (#1447) * fix: error:0308010C:digital envelope routines::unsupported * fix: process.env.UNSET_NODE_OPTIONS --- .github/workflows/nocobase-test.yml | 9 ++++++--- packages/core/cli/bin/index.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nocobase-test.yml b/.github/workflows/nocobase-test.yml index 91de994e4a..c1102272c1 100644 --- a/.github/workflows/nocobase-test.yml +++ b/.github/workflows/nocobase-test.yml @@ -19,7 +19,7 @@ jobs: sqlite-test: strategy: matrix: - node_version: ['16'] + node_version: ['16', '18'] runs-on: ubuntu-latest container: node:${{ matrix.node_version }} steps: @@ -30,6 +30,7 @@ jobs: node-version: ${{ matrix.node_version }} cache: 'yarn' - run: yarn install + - run: yarn build - name: Test with Sqlite run: yarn test env: @@ -39,7 +40,7 @@ jobs: postgres-test: strategy: matrix: - node_version: ['16'] + node_version: ['16', '18'] runs-on: ubuntu-latest container: node:${{ matrix.node_version }} @@ -66,6 +67,7 @@ jobs: node-version: ${{ matrix.node_version }} cache: 'yarn' - run: yarn install + - run: yarn build - name: Test with postgres run: yarn test env: @@ -79,7 +81,7 @@ jobs: mysql-test: strategy: matrix: - node_version: ['16'] + node_version: ['16', '18'] runs-on: ubuntu-latest container: node:${{ matrix.node_version }} services: @@ -97,6 +99,7 @@ jobs: node-version: ${{ matrix.node_version }} cache: 'yarn' - run: yarn install + - run: yarn build - name: Test with MySQL run: yarn test env: diff --git a/packages/core/cli/bin/index.js b/packages/core/cli/bin/index.js index 06bba306e3..3b3ac86a8e 100755 --- a/packages/core/cli/bin/index.js +++ b/packages/core/cli/bin/index.js @@ -35,6 +35,21 @@ for (const key in env) { } } +if (require('semver').satisfies(process.version, '>16') && !process.env.UNSET_NODE_OPTIONS) { + if (process.env.NODE_OPTIONS) { + let opts = process.env.NODE_OPTIONS; + if (!opts.includes('--openssl-legacy-provider')) { + opts = opts + ' --openssl-legacy-provider'; + } + if (!opts.includes('--no-experimental-fetch')) { + opts = opts + ' --no-experimental-fetch'; + } + process.env.NODE_OPTIONS = opts; + } else { + process.env.NODE_OPTIONS = '--openssl-legacy-provider --no-experimental-fetch'; + } +} + const cli = require('../src/cli'); cli.parse(process.argv);