Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error Error in bail mode: Error: callback(): The callback was already called and how to mitigate #94

Open
hlovdal opened this issue Jun 20, 2023 · 2 comments

Comments

@hlovdal
Copy link

hlovdal commented Jun 20, 2023

TL;DR

If you get error Error in bail mode: Error: callback(): The callback was already called when running npm run build then you need to set the NODE_OPTIONS environment variable to include --openssl-legacy-provider.

Details

I created a test project by running node .../src/github/userscripter/bin/cli.js init followed by running npm install and npm run build, and the build command failed with

ℹ 「atl」: Using tsconfig.json from .../userscript/test1/tsconfig.json
Error in bail mode: Error: callback(): The callback was already called.
    at context.callback (.../userscript/test1/node_modules/loader-runner/lib/LoaderRunner.js:106:10) Error: callback(): The callback was already called.
    at context.callback (.../userscript/test1/node_modules/loader-runner/lib/LoaderRunner.js:106:10)

After making some debug modifications to node_modules/loader-runner/lib/LoaderRunner.js I noticed the following in the debug output

    error: ModuleParseError: Module parse failed: error:0308010C:digital envelope routines::unsupported
    File was processed with these loaders:
     * ./node_modules/awesome-typescript-loader/dist/entry.js
     * ./node_modules/restrict-imports-loader/dist/index.js
    You may need an additional loader to handle the result of these loaders.
    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 (.../userscript/test1/node_modules/webpack/lib/util/createHash.js:135:53)
        at NormalModule._initBuildHash (.../userscript/test1/node_modules/webpack/lib/NormalModule.js:417:16)
        at handleParseResult (.../userscript/test1/node_modules/webpack/lib/NormalModule.js:477:10)
        at .../userscript/test1/node_modules/webpack/lib/NormalModule.js:500:6
        at .../userscript/test1/node_modules/webpack/lib/NormalModule.js:358:12
        ...

which matched the part about "digital envelope routines::unsupported" from this comment, and when I ran

env NODE_OPTIONS=--openssl-legacy-provider npm run build

then the build succeeded.

$ npm --version
9.6.0
$ node --version
v16.18.1
@SimonAlling
Copy link
Owner

Awesome! That's been a major pain point for me as well lately. I don't remember exactly what the context was, but the next time I face this error, I'll keep this issue in mind!

@SimonAlling
Copy link
Owner

Yeah, this happens with Node 18 and 20 btw, but not with Node 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants