Default Node-red flow and pnpm


#1

I made a nodered flow yesterday and this morning nodered started empty.
In .node-red/ there are multiple flows_XXX.json files so at least flows are here but for unknown reason they are not visible.
It’s my second node-red test and the first one went to lalaland too (I didn’t investigate).
Before going further, do you had this behavior with glitch and node-red?
Or is there some limitation regarding node-red?

Added after Gareth reply:
On a new install, I realize that pnpm comes by default and it links to packages (which is a very good idea for a platform like glitch :slight_smile:).
I had to fix a node-red package (see the issue, not fixed yet). I edited ./.registry.npmjs.org/node-red-contrib-socketio/1.0.5/node_modules/node-red-contrib-socketio/socketio.js

Does it mean that all node_modules are shared (/rbd/pnpm-volume/app/node_modules) for everyone? Or per user? Or else?


Accesing files that dont show up
#2

I’m not familiar with node-red or know of other people having used it on Glitch. I’m assuming the problem is where it’s storing its data. You can only rely on data within the app directory remaining, so if it’s possible to configure it - set it to there.

By not visible do you mean in the Glitch editor or within the Node-red software? In the editor, any files stored in a hidden folder (those prefaced with .) aren’t shown.


#3

Thanks Gareth,
I meant, not visible in node-red. Node files (json) are present in .node-red/ (hence hidden).
I deployed multiple node-red installs on digital ocean and never got a missing flow like this time.
Hopefully it’s a test server, nothing bad.
I remixed an existing node-red glitch and I suspect some funky settings to come with it.
I’ll start again, from scratch.


#4

With a new node-red install from scratch, problem is still the same, node is not showing up after one day without activity.


#5

You can try to switch to npm to see if this fixes your issue. With npm, packages installed will take up space in your project, so depending on the size of your dependencies, they might not fit. To enable npm, run enable-npm in the console.


#6

Thanks, I’ll try that.
for other projects pnpm is a smart move though,
does change on packages are for all users? Or per user?


#7

I am not sure I understand the question. pnpm allows the cache to be shared among several projects, but any change that a project does to its own copy, remains on the package itself and doesn’t get shared.


#8

the path seems out of my project but I’m not sure if you jail or another way to prevent changing the core file.


#9

yes, as I said in the previous message, the changes you make do not change the original file. If the issue you’re having consist in this change to be lost after a while, this is normal. With pnpm, the node_modules folder is managed outside of the project, so any change you do inside of it is not guaranteed to stay there after the project is stopped.

You should bundle this edit as part of the startup script of your project. I can help you with that :slight_smile:


#10

I switched to npm now
But trust me, yesterday the changes on the original file at /.registry.npmjs.org/node-red-contrib-socketio/1.0.5/node_modules/node-red-contrib-socketio/socketio.js were taken in account, at least for my project.
If when using pnpm, changes to /.registry.npmjs.org/ are kept per user, I could continue using pnpm for other projects, if it’s global I should use npm, hence my question.

My initial problem with the node not being showed up when node-red restarts is not related to the package fix, I just understand that and I should have made another topic.


#11

I’m interested to learn how to patch while starting. Any example?


#12

I trust you :slight_smile:

When you make changes to a file inside node_modules, the change takes effect, and it only affects your project until it gets stopped. This is why after 24 hours you don’t see the change anymore.

I strongly encourage you to continue using pnpm, but if you need to edit files inside node_modules, you have to make sure the file is patched, as you correctly discovered.

It should be very easy:

  1. copy somewhere in your project the files you want to patch, with the patch already applied. Let’s call them socketio-edited.js and chat-page-edited.js.

  2. Create a file named patch-node-red.sh with a content similar to this:

    #!/bin/bash
    
    cp socketio-edited.js node_modules/.registry.npmjs.org/node-red-contrib-socketio/1.0.5/node_modules/node-red-contrib-socketio/socketio.js
    
    # probably same for chat-page-edited.js, I don't know if you need this too
    
  3. in your package.json, add a "prestart" field:

"prestart": "bash ./patch-node-red.js"

if something is not clear, feel free to share the project name with me so I can take a look and fix it for you :slight_smile:


How to edit files of Node Modules?
#13

Great thanks!
I’ll try what I learnt and let you know if anything doesn’t work :slight_smile:
Have a great day.