bigcommerce / stencil-cli

BigCommerce Stencil emulator for local theme development
https://developer.bigcommerce.com/stencil-docs
BSD 4-Clause "Original" or "Old" License
102 stars 142 forks source link

Error running `stencil bundle` on Windows/Git Bash with Node 18.15.0 (Error: digital envelope routines::unsupported) #1108

Closed matthewvolk closed 1 year ago

matthewvolk commented 1 year ago

Expected behavior

Documentation (https://developer.bigcommerce.com/stencil-docs/installing-stencil-cli/installing-stencil) states Stencil CLI is compatible with Node v18.15.0.

Actual behavior

Running stencil bundle on Windows with Git Bash results in the following:

$ stencil bundle
Validating theme..
SCSS Parsing Started...
Template Parsing Started...
Language Files Parsing Started...
Building Theme Schema File..
Schema Translations Parsing Started...
Theme task Started...
ok
Schema Translations Parsing Finished
ok
Language Files Parsing Finished
ok
Theme Schema Building Finished
ok
SCSS Parsing Finished
ok
Template Parsing Finished 
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 module. exports (E: \Bigcommerce\ MeddMax+B2B+9-22-22+(3) -6.0.1+-+b26+-+3.7\ node_modules \webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (E:\Bigcommerce\MeddMax+B2B+9-22-22+(3)-6.0.1 +-+b2b+-+3.7\node_modules \webpack\lib\NormalModule.js:417:16)
    at handleParseError (E:\Bigcommerce\ MeddMax+B2B+9-22-22+(3)-6.0.1+-+b26+-+3.
7\node_modules \webpack\lib\NormalModule.js:471:10)
    at E: \Bigcommerce\ MeddMax+B2B+9-22-22+(3)-6.0.1+-+b2b+-+3.7\node_modules \web pack\lib\NormalModule.js:503:5
    at E: Bigcommerce\MeddMax+B2B+9-22-22+(3)-6.0.1+-+b2b+-+3.7\node_modules\web pack\lib\NormalModule.js: 358:12
    at E: \Bigcommerce\MeddMax+B2B+9-22-22+(3)-6.0.1+-+b2b+-+3.7\node_modules\loa der-runner\ lib\LoaderRunner. js: 373:3
    at iterateNormalLoaders (E: \Bigcommerce\ MeddMax+B2B+9-22-22+(3) -6.0.1+-+b2b+
-+3. 7\node_modules \loader-runner\lib\LoaderRunner.js:214:10)
    at Array. <anonymous> (E: \Bigcommerce\ MeddMax+B2B+9-22-22+(3) -6.0.1+-+b26+-+3
•7\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (E:\Bigcommerce\ MeddMax+B2B+9-22-22+(3)-6.0.1+-+b26+-+3.
7\node_modules \enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at E: Biqcommerce\MeddMax+B2B+9-22-22+(3)-6.0.1+-+b2b+-+3.7\ node modules\enh anced-resolve\lib\CachedInputFileSystem.js:91:9
    at E: \Bigcommerce\MeddMax+B2B+9-22-22+(3)-6.0.1+-+b2b+-+3.7\node_modules\gra ceful-fs\graceful-fs.js:123:16
    at FReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file context :68:3) {
  openssIErrorStack: [ 'error:03000086:digital envelope routines: :initialization error'
], 
    library: 'digital envelope routines',
    reasons: 'unsupported', 
    code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node. js v18.15.0 
worker terminated

Workarounds

Downgrade to Node v16.x.x

Steps to reproduce behavior

Run stencil bundle on Windows with Git Bash using Node 18.15.0

Environment

Stencil-cli version stencil --version: Unsure - problem reported in BigCommerce Discord, waiting on community member to get back to me with stencil version.

Node version node -v: 18.15.0

NPM version npm -v: 9.5.0

OS: Windows (Git Bash)

jairo-bc commented 1 year ago

Hi @matthewvolk, looking at the stack trace, I assume your theme is running on webpack 4, which is not supporting Node 18. You would need to update webpack from 4 to 5 and related to it packages to get your theme running on Node 18. I would recommend going through Cornerstone PR to see which packages were update there.

matthewvolk commented 1 year ago

Thanks @jairo-bc! I talked to the community member and they mentioned your suggestion of walking through the changes in the Cornerstone PR helped to resolve their issue.