Disappearing node_modules

Hi I have some additional modules that I use.
i2c-bus
ina219
ina219-sync
A couple of times recently these have disappeared and node red has stopped because they are called upon in settings.js
I notice that they have been replaced as hidden files called:
.i2c-bus-eVViQg5K
.ina219-tsDZ2lkp
.ina219-sync-cWMQSGw7

Why does this happen and how do I stop it.
thanks

How did you install the modules?

I use docker. In nodered folder:
dbash
cd /data
npm install ina219

It all worked fine for a few weeks before this happened.

How did you map the /data folder to the node red data folder when creating the container ?

Not sure I understand but this is a couple of lines from docker-compose.yml

image: nodered/node-red
volumes:
  - ./data:/data

Tagged the thread as docker related.

Do you mean that initially you see in /data/node_modules the folder ina219 but later instead of that you see /data/node_modules/.ina219-tsDZ2lkp

Is your system accessible via the internet?

Yes that's correct. I have remote Tailscale access to the system. I believe it to be pretty secure

What is in those folders?

Not sure what you're asking. Tailscale is enabled on my GLinet router. The docker nodered container is standard with node modules and setting.js etc in the data folder.

I wasn't clear, sorry. I meant what is in the strange folders?
Also, what is in package.json before and after the rename?

It does smell of a hacked system to me, though I hear what you are saying about Tailscale.

The first time it happened I just renamed the altered folders back to the original and it worked again. I then made a copy of the data folder and twice since then have just restored that copy. The altered folders looked normal with nothing untoward in the package.json

Is package.json still asking for ina219? I would not have expected that to work when the folder has, apparently, been renamed. Or perhaps it did not work.

Have you looked into the files in the renamed folder to see if they are identical to the original? It is odd though, I cannot see why a hacker would rename the folder. Rather he would hack the contents.

I agree. The renamed folder still references ina219 and did not work until I renamed it to the original again. Very strange and not what a hacker would do I think. Something or someone did however make the change.
Just to recap. Node red failed and complained of something within settings.js.
I tracked it down to:

functionGlobalContext: {
//os:require('os'),
i2c:require('i2c-bus'),
inaJM:require('ina219'),
ina:require('ina219-sync'),
fs:require('fs')
},

Then I noticed that those modules were missing but spotted hidden files with similar names. I renamed the 3 files to original and all worked again.

Those odd names look like the temporary folder names you get when updating a package with npm. Sometimes, npm cannot delete them for reasons I've never managed to track down.

But to me, the implication is that something tried to update the package but failed.

That sounds like a reasonable conclusion. My issue now is how to stop the system doing auto upgrades as it "kills" node red.

Well, you probably need to work out why npm is failing and fix that. It is likely to be a permissions issue I would guess. But then I don't use Docker that much so not sure what might be happening.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.