我创建了默认的IntelliJ IDEA React项目,并得到了这个:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at module.exports (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/user/Programming Documents/WebServer/untitled/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/user/Programming Documents/WebServer/untitled/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/user/Programming Documents/WebServer/untitled/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

这似乎是最近才出现的问题——webpack在4天前遇到了这个问题,目前仍在处理。


当前回答

我在使用Node.js v18.4.0构建hoppscotch时遇到了同样的错误,并且设置NODE_OPTIONS=——openssl-legacy-provider拯救了我!

Logs

D:\code\rust\hoppscotch-app\hoppscotch>pnpm install && pnpm run generate
Scope: all 5 workspace projects
Lockfile is up-to-date, resolution step is skipped
Already up-to-date
packages/codemirror-lang-graphql prepare$ rollup -c
│ Browserslist: caniuse-lite is outdated. Please run:
│   npx browserslist@latest --update-db
│   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
│
│ src/index.js → dist/index.cjs, ./dist...
│ created dist/index.cjs, ./dist in 2.8s
└─ Done in 4.8s
packages/hoppscotch-data prepare$ tsup src --dts
[20 lines collapsed]
│ CJS dist\chunk-LZ75CAKS.js     13.00 B
│ DTS Build start
│ DTS ⚡️ Build success in 2261ms
│ DTS dist\index.d.ts              714.00 B
│ DTS dist\rest\index.d.ts         2.18 KB
│ DTS dist\graphql\index.d.ts      589.00 B
│ DTS dist\collection\index.d.ts   1.30 KB
│ DTS dist\rest\content-types.d.ts 473.00 B
│ DTS dist\rest\HoppRESTAuth.d.ts  882.00 B
│ DTS dist\type-utils.d.d.ts       1.00 B
└─ Done in 3.8s
packages/hoppscotch-js-sandbox postinstall$ pnpm run build
│ > @hoppscotch/js-sandbox@1.0.0 build D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-js-sandbox
│ > npx tsc
└─ Done in 8.7s
. prepare$ husky install
│ husky - Git hooks installed
└─ Done in 300ms
packages/hoppscotch-app postinstall$ pnpm run gql-codegen
[12 lines collapsed]
│ [14:58:01] Load GraphQL documents [started]
│ [14:58:01] Load GraphQL documents [completed]
│ [14:58:01] Generate [started]
│ [14:58:01] Generate [completed]
│ [14:58:01] Generate helpers/backend/backend-schema.json [completed]
│ [14:58:02] Load GraphQL documents [completed]
│ [14:58:02] Generate [started]
│ [14:58:02] Generate [completed]
│ [14:58:02] Generate helpers/backend/graphql.ts [completed]
│ [14:58:02] Generate outputs [completed]
└─ Done in 4s

> hoppscotch-app@2.2.1 generate D:\code\rust\hoppscotch-app\hoppscotch
> pnpm -r do-build-prod

Scope: 4 of 5 workspace projects
packages/hoppscotch-js-sandbox do-build-prod$ pnpm run build
│ > @hoppscotch/js-sandbox@1.0.0 build D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-js-sandbox
│ > npx tsc
└─ Done in 7.5s
packages/hoppscotch-app do-build-prod$ pnpm run generate
│ > hoppscotch-app@2.2.1 generate D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-app
│ > nuxt generate --modern
│ i Sentry reporting is disabled (no DSN has been provided)
│ i Production build
│ i Bundling only for client side
│ i Target: static
│ i Using components loader to optimize imports
│ i Discovered Components: node_modules/.cache/nuxt/components/readme.md
│ √ Builder initialized
│ √ Nuxt files generated
│ i Compiling Client
│  ERROR  Error: error:0308010C:digital envelope routines::unsupported
│     at new Hash (node:internal/crypto/hash:67:19)
│     at Object.createHash (node:crypto:133:10)
│     at module.exports (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib
│     at NormalModule._initBuildHash (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_module
│     at handleParseError (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\l
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at runSyncOrAsync (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at Array.<anonymous> (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loa
│     at Storage.finished (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\enhanced-resolve@4.5.0\node_modules\e
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\enhanced-resolve@4.5.0\node_modules\enhanced-resolve\li
│  WARN  Browserslist: caniuse-lite is outdated. Please run:
│   npx browserslist@latest --update-db
│   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
│  ERROR  error:0308010C:digital envelope routines::unsupported
│   at new Hash (node:internal/crypto/hash:67:19)
│   at Object.createHash (node:crypto:133:10)
│   at module.exports (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\u
│   at NormalModule._initBuildHash (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\
│   at handleParseError (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js:5
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js:3
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Loader
│   at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\lo
│   at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\lo
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Loader
│   at context.callback (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\babel-loader@8.2.3_@babel+core@7.16.12\node_modules\babel
│ D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\LoaderRunne
│                       throw e;
│                       ^
│ Error: error:0308010C:digital envelope routines::unsupported
│     at new Hash (node:internal/crypto/hash:67:19)
│     at Object.createHash (node:crypto:133:10)
│     at module.exports (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib
│     at NormalModule._initBuildHash (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_module
│     at handleParseError (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\l
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at context.callback (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\load
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\cache-loader@4.1.0_webpack@4.46.0\node_modules\cache-lo
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\graceful-fs@4.2.8\node_modules\graceful-fs\graceful-fs.
│     at FSReqCallback.oncomplete (node:fs:201:23) {
│   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
│   library: 'digital envelope routines',
│   reason: 'unsupported',
│   code: 'ERR_OSSL_EVP_UNSUPPORTED'
│ }
│ Node.js v18.4.0
│  ELIFECYCLE  Command failed with exit code 1.
└─ Failed in 8.3s
D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-app:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  hoppscotch-app@2.2.1 do-build-prod: `pnpm run generate`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

D:\code\rust\hoppscotch-app\hoppscotch>npx browserslist@latest --update-db
Need to install the following packages:
  browserslist@4.20.4
Ok to proceed? (y) y
Latest version:     1.0.30001357
Updating caniuse-lite version
$ pnpm up caniuse-lite
caniuse-lite has been successfully updated

No target browser changes

D:\code\rust\hoppscotch-app\hoppscotch>pnpm install && pnpm run generate
Scope: all 5 workspace projects
Lockfile is up-to-date, resolution step is skipped
Already up-to-date
packages/codemirror-lang-graphql prepare$ rollup -c
│ Browserslist: caniuse-lite is outdated. Please run:
│   npx browserslist@latest --update-db
│   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
│
│ src/index.js → dist/index.cjs, ./dist...
│ created dist/index.cjs, ./dist in 2.8s
└─ Done in 4.8s
packages/hoppscotch-data prepare$ tsup src --dts
[20 lines collapsed]
│ CJS dist\chunk-JUWXSDKJ.js     1010.00 B
│ DTS Build start
│ DTS ⚡️ Build success in 2250ms
│ DTS dist\index.d.ts              714.00 B
│ DTS dist\rest\index.d.ts         2.18 KB
│ DTS dist\graphql\index.d.ts      589.00 B
│ DTS dist\collection\index.d.ts   1.30 KB
│ DTS dist\rest\content-types.d.ts 473.00 B
│ DTS dist\rest\HoppRESTAuth.d.ts  882.00 B
│ DTS dist\type-utils.d.d.ts       1.00 B
└─ Done in 3.7s
packages/hoppscotch-js-sandbox postinstall$ pnpm run build
│ > @hoppscotch/js-sandbox@1.0.0 build D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-js-sandbox
│ > npx tsc
└─ Done in 8.5s
. prepare$ husky install
│ husky - Git hooks installed
└─ Done in 335ms
packages/hoppscotch-app postinstall$ pnpm run gql-codegen
[12 lines collapsed]
│ [15:02:37] Load GraphQL documents [started]
│ [15:02:37] Load GraphQL documents [completed]
│ [15:02:37] Generate [started]
│ [15:02:37] Generate [completed]
│ [15:02:37] Generate helpers/backend/backend-schema.json [completed]
│ [15:02:38] Load GraphQL documents [completed]
│ [15:02:38] Generate [started]
│ [15:02:38] Generate [completed]
│ [15:02:38] Generate helpers/backend/graphql.ts [completed]
│ [15:02:38] Generate outputs [completed]
└─ Done in 3.8s

> hoppscotch-app@2.2.1 generate D:\code\rust\hoppscotch-app\hoppscotch
> pnpm -r do-build-prod

Scope: 4 of 5 workspace projects
packages/hoppscotch-js-sandbox do-build-prod$ pnpm run build
│ > @hoppscotch/js-sandbox@1.0.0 build D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-js-sandbox
│ > npx tsc
└─ Done in 6.9s
packages/hoppscotch-app do-build-prod$ pnpm run generate
│ > hoppscotch-app@2.2.1 generate D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-app
│ > nuxt generate --modern
│ i Sentry reporting is disabled (no DSN has been provided)
│ i Production build
│ i Bundling only for client side
│ i Target: static
│ i Using components loader to optimize imports
│ i Discovered Components: node_modules/.cache/nuxt/components/readme.md
│ √ Builder initialized
│ √ Nuxt files generated
│ i Compiling Client
│  ERROR  Error: error:0308010C:digital envelope routines::unsupported
│     at new Hash (node:internal/crypto/hash:67:19)
│     at Object.createHash (node:crypto:133:10)
│     at module.exports (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib
│     at NormalModule._initBuildHash (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_module
│     at handleParseError (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\l
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at runSyncOrAsync (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at Array.<anonymous> (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loa
│     at Storage.finished (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\enhanced-resolve@4.5.0\node_modules\e
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\enhanced-resolve@4.5.0\node_modules\enhanced-resolve\li
│  WARN  Browserslist: caniuse-lite is outdated. Please run:
│   npx browserslist@latest --update-db
│   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
│  ERROR  error:0308010C:digital envelope routines::unsupported
│   at new Hash (node:internal/crypto/hash:67:19)
│   at Object.createHash (node:crypto:133:10)
│   at module.exports (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\u
│   at NormalModule._initBuildHash (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\
│   at handleParseError (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js:5
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js:3
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Loader
│   at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\lo
│   at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\lo
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Loader
│   at context.callback (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader
│   at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\babel-loader@8.2.3_@babel+core@7.16.12\node_modules\babel
│ D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\LoaderRunne
│                       throw e;
│                       ^
│ Error: error:0308010C:digital envelope routines::unsupported
│     at new Hash (node:internal/crypto/hash:67:19)
│     at Object.createHash (node:crypto:133:10)
│     at module.exports (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib
│     at NormalModule._initBuildHash (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_module
│     at handleParseError (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\l
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\webpack@4.46.0\node_modules\webpack\lib\NormalModule.js
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at iterateNormalLoaders (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\loader-runner\lib\Load
│     at context.callback (D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\loader-runner@2.4.0\node_modules\load
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\cache-loader@4.1.0_webpack@4.46.0\node_modules\cache-lo
│     at D:\code\rust\hoppscotch-app\hoppscotch\node_modules\.pnpm\graceful-fs@4.2.8\node_modules\graceful-fs\graceful-fs.
│     at FSReqCallback.oncomplete (node:fs:201:23) {
│   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
│   library: 'digital envelope routines',
│   reason: 'unsupported',
│   code: 'ERR_OSSL_EVP_UNSUPPORTED'
│ }
│ Node.js v18.4.0
│  ELIFECYCLE  Command failed with exit code 1.
└─ Failed in 8.2s
D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-app:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  hoppscotch-app@2.2.1 do-build-prod: `pnpm run generate`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

D:\code\rust\hoppscotch-app\hoppscotch>echo %NODE_OPTIONS%
%NODE_OPTIONS%

D:\code\rust\hoppscotch-app\hoppscotch>set NODE_OPTIONS=--openssl-legacy-provider

D:\code\rust\hoppscotch-app\hoppscotch>echo %NODE_OPTIONS%
--openssl-legacy-provider

D:\code\rust\hoppscotch-app\hoppscotch>pnpm run generate

> hoppscotch-app@2.2.1 generate D:\code\rust\hoppscotch-app\hoppscotch
> pnpm -r do-build-prod

Scope: 4 of 5 workspace projects
packages/hoppscotch-js-sandbox do-build-prod$ pnpm run build
│ > @hoppscotch/js-sandbox@1.0.0 build D:\code\rust\hoppscotch-app\hoppscotch\packages\hoppscotch-js-sandbox
│ > npx tsc
└─ Done in 7.1s
packages/hoppscotch-app do-build-prod$ pnpm run generate
[732 lines collapsed]
│ √ Generated route "/vi/enter"
│ √ Generated route "/vi/graphql"
│ √ Generated route "/vi/join-team"
│ √ Generated route "/vi/profile"
│ √ Generated route "/vi/realtime"
│ √ Generated route "/vi/settings"
│ √ Generated route "/"
│ √ Client-side fallback created: 404.html
│ i Generating sitemaps
│ √ Generated /sitemap.xml
└─ Done in 6m 37.1s

D:\code\rust\hoppscotch-app\hoppscotch>

其他回答

如果遇到此错误,并且不想更改主配置,则可以使用以下方法进行简单的修复。不过,我不确定这是否被推荐为一种好的做法。

请随意改正。

最初,假设这是我的包的脚本部分。json文件:

...
"version": "1.0.0",
  "scripts": {
    ...
    "build": "npm run build:test-app:testing",
    "build:test-app:testing": "ng build test-app --deploy-url  https://test-app.com/ --configuration=test-config",
    ...
  },
  "private": true,
...

为了使用这个导出NODE_OPTIONS=——openssl-legacy-provider,您可以执行以下操作:

"version": "1.0.0",
  "scripts": {
....
    "build": "NODE_OPTIONS=--openssl-legacy-provider npm run build:test-app:testing”,
    "build:test-app:testing": "NODE_OPTIONS=--openssl-legacy-provider ng build test-app --deploy-url  https://test-app.com/ --configuration=test-config"
...
  },
  "private": true,

注意构建脚本。我添加了一个选项:NODE_OPTIONS=——openssl-legacy-provider

这有助于在Node.js version 17中解决此错误。

对于那些可以灵活更改构建系统的Node.js版本的人,只需切换到低于17的版本,例如,版本16。

对于Docker,最初使用this的用例,它总是提取最新版本:

...
FROM node:alpine
...

你可以切换到如下内容:

...
FROM node:16-alpine3.12
...

在你更改npm版本或进行任何配置更改之前,只需运行npm update将你的包更新到最新的小版本。

这为我解决了问题。

我通过使用LTS版本修复:

echo "lts" > .nvmrc
nvm install

React Native有一个有bug的脚本来查找Node.js可执行文件的路径。

这将通过节点版本管理器将版本设置为Node.js的最新稳定版本。

我发现即使Node.js在我的路径中,如果我有一个~/。它将尝试在NVM中找到用途,但失败了。这将当前节点设置为链接到~/中的节点。nvm,因此React Native可以找到。

在更新webpack之后,我通过更新我的babel-loader版本来解决这个错误。然而,这可能是由于另一个加载器或插件,加载器运行器出现在控制台输出的原始问题。见此处评论

对于Angular应用:

你也可以在package.json中编辑npm启动脚本。而不是

"start": "ng serve -o"

to

"start": "set NODE_OPTIONS=--openssl-legacy-provider && ng serve -o"

当你在终端/命令行中运行npm run start时,它会首先设置NODE_OPTIONS来避免这个问题。