2

So I get this annoying error:

enter image description here

I saw some posts talking about it, however, either they don't have an answer, or the answer didn't help me solving this error. I had this error before, and I can't remember how I solved it.

This error came after I have accidentally removed the node_modules package, then I have re-installed it with npm i my_app.

I have already downgraded nodejs but I feel that playing with the versions is just a waste of time. Instead, I will be glad to actually know what's the problem and how to fix it.

  • I have removed node-rdkafka from my project and it's working, so the problem is related to node-rdkafka. I can't find what is the reason that this is happening.

Thanks!

Chopin
  • 113
  • 1
  • 10

1 Answers1

0

node-rdkafka is a C++ addon it isn't installed as a vanilla js module.

in order to build this kind of addon you need to verify your environment

has C++ compiler, python and node-gyp properly installed

then after verifying the:

run the following command in your node project dir :

rm -rf node_modules

rm -rf package-lock.json

npm cache clean --force

npm i

then:

if the installation pass without any issue navigate to : node_modules -> node-rdkafka -> build -> deps

inside it should look the same has here except the file postfix should be .so instead of .dylib (i am using OSX)

enter image description here

now everything should work just fine

Naor Tedgi
  • 5,204
  • 3
  • 21
  • 48
  • I have done all the commands, and have same package as you but still same issue. – Chopin Oct 18 '22 at 19:53
  • Maybe the new version is behind all this? because I used the 2.13.0 version until today when I accidentally removed the node_module package. – Chopin Oct 18 '22 at 23:22
  • 1
    I have resolved it by giving each package its own json package file. Somehow the node_modules package has linked to a false node_modules package so I removed it, then separated the big json package in main package to the packages. I think it's the correct way and it makes sense to give each package its own json package file. :) – Chopin Oct 19 '22 at 01:31
  • Not sure i understand why you got more the one package.json file – Naor Tedgi Oct 19 '22 at 03:51
  • Because I have a few subsystems and each has its own modules it uses. So it makes sense that each will have a package.json file for the modules it uses. Instead, what I did is to put one package.json file only in one of my subsystems to hold all the modules which are used by all the subsystems together, which is totally wrong. – Chopin Oct 19 '22 at 11:07