Zaid-Ajaj / fable-getting-started

Template for getting started with Fable
MIT License
22 stars 14 forks source link

Error thrown by LoadRunner.js as part of webpack: callback was already called #32

Open mrwizard82d1 opened 2 years ago

mrwizard82d1 commented 2 years ago

Platform: Windows 10 Shell: Git Bash for Windows (with zsh) Nodejs: v18.4.0 fable-compiler: 2.13.0

I am trying to run through the code examples from "The Elmish Book". (Thank you very much for this book. Reading it really helps understand what's going on.)

I cloned this repository, removed the .git directory (since I have a "parent" local git repository already), and then executed npm install. Installing packages succeeded with warnings and some audit flags.

I then ran npm run build and encountered an error I'm at loss to investigate. Here's my shell output:

larry.jones in fable-getting-started on laj/proto/use-npm λ npm run build

build webpack

fable-compiler 2.13.0 fable: Compiled src\App.fsproj C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106 throw new Error("callback(): The callback was already called."); ^

Error: callback(): The callback was already called. at context.callback (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106:10) at C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\fable-loader\index.js:147:9 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.4.0

I've joined the F# Software Foundation and am awaiting my invitation to the slack channel, but thought this repository might be an appropriate place to raise this issue.

Thanks.

P.S. My first set of steps, which produced the same error, involved deleting the node_modules directory and package-lock.json and running yarn install. This start eventually led to the same error.

mrwizard82d1 commented 2 years ago

Tried simply running the development version with npm start. This, much to my surprise, seems to work. :(

mrwizard82d1 commented 2 years ago

After my "success" running npm start, I went back to my yarn branch, deleted the node_modules directory, ran yarn install.

When I now run yarn run build, everything seems to work.

A mystery of software. Not very satisfying, but lessens my immediate need for help.

mrwizard82d1 commented 2 years ago

And I'm sure you will hate me. ;)

After successfully running and changing the message from the Git Bash shell as I previously described, I tried opening the fable-getting-started directory with WebStorm.

WebStorm appeared to successfully load the project; however, when I run npm build from their npm tool window, I see the "callback already called" error again:

C:\Users\larry.jones\AppData\Roaming\npm\yarn.cmd run build yarn run v1.22.19 $ webpack fable-compiler 2.13.0 fable: Compiled src\App.fsproj C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106 throw new Error("callback(): The callback was already called."); ^

Error: callback(): The callback was already called.
at context.callback (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106:10) at C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\fable-loader\index.js:147:9 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

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

Process finished with exit code 1

FYI. I see the same error running npm run build in the Terminal window hosted by WebStorm.

Additionally, I did just verify that the terminal I have configured for WebStorm is C:\Program Files\Git\bin\bash.exe.

mrwizard82d1 commented 2 years ago

And for the continued mystery that is software...

Before I "successfully" executed npm start, I encountered the following "known" (to me?) error:

node:internal/crypto/hash:67 this[kHandle] = new _Hash(algorithm, xofLen); ^

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 (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\webpack\lib\util\createHash.js:135:53) at NormalModule._initBuildHash (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\webpack\lib\NormalModule.js:417:16) at handleParseError (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\webpack\lib\NormalModule.js:471:10) at C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\webpack\lib\NormalModule.js:503:5 at C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\webpack\lib\NormalModule.js:358:12 at C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:373:3 at iterateNormalLoaders (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:214:10) at Array. (C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:205:4) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' }

I've run into this before trying to run tutorials based on older versions of Nodejs. The fix that I employed previously and used again was to set an environment variable, export NODE_OPTIONS=--openssl-legacy-provider.

When I added this environment variable to my WebStorm build configuration, everything worked again. I suspect it would work in WebStorm from the terminal if I set this variable also.

With apologies to the writers of the movie, "Clue," and probably others, perhaps "'callback already called' is just a red herring."

allenu commented 1 year ago

I was just going through The Elmish Book too (on a Mac) and encountered the same error you saw in LoadRunner.js.

I dug around and found this Stack Overflow post: https://stackoverflow.com/questions/66028314/error-node-modules-callback-was-already-called

I ended up doing

npm install -g npm-check-updates
ncu -u
npm install

And it gave me a new error:

fable-compiler 2.13.0
asset main.js 877 bytes [emitted] (name: main)
./src/App.fsproj 39 bytes [built] [code generated] [1 error]

ERROR in ./src/App.fsproj
Module build failed (from ./node_modules/fable-loader/index.js):
Error: The specified file name or path is too long, or a component of the specified path is too long.
    at /Users/allenussher/Development/fsharp/elmish-book/fable-getting-started/node_modules/fable-loader/index.js:98:22
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Which apparently affects only Apple silicon... I then dug into that issue and found an issue on Fable's github: https://github.com/fable-compiler/Fable/issues/3239

Apparently fable-loader isn't used anymore, so I ended up following the instructions here to create a new Fable project from scratch: https://fable.io/docs/2-steps/your-first-fable-project.html

I figured I could just copy-paste the code from The Elmish Book into it.

Well, I eventually ran into yet another problem when I run npm start (same one encountered above):

Watching src
node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
...

I also did the export NODE_OPTIONS=--openssl-legacy-provider thing and then that finally fixed it.