WiredEntrepreneur
WiredEntrepreneur

Reputation: 161

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.

Upvotes: 11

Views: 38571

Answers (10)

Ricardo Saracino
Ricardo Saracino

Reputation: 1420

I had this error because i was using an incompatible version of Angular with Node

Is there a compatibility list for Angular / Angular-CLI and Node.js?

Upvotes: 0

Acea Spades
Acea Spades

Reputation: 87

I ran into this issue in a React project. The solution was to bump yarn down from v2.4.2 to v1.22.19, and Node from v19.2.0 to v14.21.0. Kind of annoying, but this resolved the callback issue.

Upvotes: 0

devnrj
devnrj

Reputation: 1

In my case, I've craco setup for a react-app that is also a PWA enabled. I was importing some function from seperate custom module into the service-worker.js file which was causing this issue. `import {getAppVersion} from @XXX/shared'. Commenting this line did the trick.

Upvotes: 0

sigsegv
sigsegv

Reputation: 51

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.

Upvotes: 5

Oybek Odilov
Oybek Odilov

Reputation: 331

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.

Upvotes: 0

RiBi
RiBi

Reputation: 883

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.

Upvotes: 8

ImDaHeat
ImDaHeat

Reputation: 51

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 😊

Upvotes: 4

Emalindah Kimari
Emalindah Kimari

Reputation: 79

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

Upvotes: 4

elliot
elliot

Reputation: 149

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.

Upvotes: 1

WiredEntrepreneur
WiredEntrepreneur

Reputation: 161

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.

Upvotes: 2

Related Questions