trakanom / Portfolio-Site

Under construction
0 stars 0 forks source link

Build error #3

Closed trakanom closed 1 year ago

trakanom commented 1 year ago

Issue Title: Build Failure Due to SSL Error with Node.js v18.18.0

Issue Description:

When attempting to build the project using yarn build, the process fails and throws an SSL-related error: error:0308010C:digital envelope routines::unsupported. This issue is observed while using Node.js version v18.18.0.

Error Details:

Error: error:0308010C:digital envelope routines::unsupported
    ...
    at Object.createHash (node:crypto:133:10)
    ...
    at NormalModule._initBuildHash (...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:417:16)
    ...
    reason: 'unsupported',
    code: 'ERR_OSSL_EVP_UNSUPPORTED'

Context:

Reason for the Error:

The error is related to a breaking change in Node.js v17 and later, where developers patched a security vulnerability in the SSL provider. This change is incompatible with certain SSL packages in NPM if they are not updated accordingly. When SSL is utilized in Node.js v17+ without upgrading the relevant SSL packages in package.json, the aforementioned error is encountered.

Reference: StackOverflow Explanation

Suggested Fix:

1. Downgrade Node.js:

2. Update SSL-related Dependencies:

3. Alternative Node Version Management:

Steps to Reproduce:

  1. Clone the repository and navigate to the project directory.
  2. Use Node.js version v18.18.0.
  3. Run yarn install to install dependencies.
  4. Execute yarn build.

Expected Result:

Actual Result:

Additional Notes:

Attachments:


Feel free to adjust the details as per your project’s requirement and add any additional information that might be relevant to understanding and resolving the issue.

trakanom commented 1 year ago

Error log:

$ yarn build
yarn run v1.22.19
$ yarn run react-scripts build
$ ...\Portfolio-Site\node_modules\.bin\react-scripts build
Creating an optimized production build...
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (...\Portfolio-Site\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:471:10)
    at ...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:503:5
    at ...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:358:12
    at ...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at ...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (...\Portfolio-Site\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at ...\Portfolio-Site\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
...\Portfolio-Site\node_modules\react-scripts\scripts\build.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (...\Portfolio-Site\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:417:16)
    at ...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:452:10
    at ...\Portfolio-Site\node_modules\webpack\lib\NormalModule.js:323:13
    at ...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:367:11
    at ...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:233:18
    at context.callback (...\Portfolio-Site\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at ...\Portfolio-Site\node_modules\babel-loader\lib\index.js:59:103 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.18.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
trakanom commented 1 year ago

Attempted resolution with npm_config_yes=true npx yarn-audit-fix as per reference link to little effect.

trakanom commented 1 year ago

Initial fix Additional errors cleared