'Error - node_modules : Callback was already called

I am building SSR rendered Gatsby react application and I get the following error while doing "gatsby build". Been searching for a solution for this error for a good couple of days as it is hard to find out what is causing this error from the description itself. All the description says is "Callback was already called"

C:\Users\<project_folder>\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
    throw ex;
    ^
Error: Callback was already called.
at throwError (C:\Users\<project_folder>\node_modules\neo-async\async.js:16:11)
at C:\Users\<project_folder>\node_modules\neo-async\async.js:2818:7
at processTicksAndRejections (internal/process/task_queues.js:75:11)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.


Solution 1:[1]

After days of searching for a solution for this nerve-wracking. Updating all my packages, this way below, removed the error.

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

Solution 2:[2]

I am using vuejs (which uses webpack) and was running into this same issue. I was using yarn as my package manager and tried upgrading and reinstalling all my dependencies and clearing cache, nothing seemed to work.

Although I did find a solution for my case. It seems vuejs (or webpack - not entirely sure) is very case sensitive to the file and folder names, I had various case styles in my absolute folder path which seemed to cause a problem in git bash. When I used cmd however, it did work. I have reason to believe that cmd normalizes this issue.

In brief: Try cmd if git bash gave you errors.

Solution 3:[3]

After a lot of searching and doing trial and error, I found out that I need to remove Webpack from my installed packages. After I removed webpack and re-ran YARN/ NPM this error was gone.

Solution 4:[4]

I had similar error building Vuejs webpack project, But then I tried running build command using "nodejs command prompt" which was successful without error,

So I realized I should "update/upgrade Powershell" itself, which removed this darkness forever ?

Solution 5:[5]

I've had this issue unexpectedly pop-up today as well. I ended up removing the cache, public, and node_modules directories and reverting to my previous package-lock.json and package.json files. Running npm i again fixed it somehow. Not sure what the deal was.

Solution 6:[6]

Solution

Rename all your folder names to lowercase, for ex. C:/Projects/Vue-App/ to C:/projects/vue-app/.

If didn't work, delete node_modules folder and reinstall packages: npm install or yarn.

Solution 7:[7]

This can happen on Windows if your current directory on the command prompt doesn't match the casing of the folder you are in.

Let's say, for example, your project is in C:\Development\project (the Development folder has a capital letter at the start).

If the path to the current directory on your shell is C:\development\project (lowercase D in Directory, which is incorrect), which Windows will happily allow, it can cause this problem when using vue-cli. To get around it, change the current directory's path on your shell to use proper capitalization.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emalindah Kimari
Solution 2 rishi
Solution 3 WiredEntrepreneur
Solution 4 ImDaHeat
Solution 5 hondo-lane
Solution 6 Oybek Odilov
Solution 7 Karl Hill