There are folders under packages/node_modules/@node-red folder. Is that the source code? isn't that where the compiled javascript "packages" are placed? If that is the source code, does anything change to compile it and produce compiled code into output directory?
Thanks for the response. This seems to be done differently as much as I understand. When node based code packages are installed, they go into node_modules directory. But here that is being used for source code. About the compiling thing, I underdstand it is javascript, I was more thinking in terms of TS which is used mostly for bigger stuff for better organization which needs compiling/transpiling. I made a mistake in saying that the output goes to node_modules folder, it is the node packages that go into that folder when installed.
We should be clear for future readers.
Typically, when node-red is ran for the first time via the command node-red, a "userDir" is created. Often this "userDir" is ~/.node-red or c:\user\.node-red
When a user adds node-red nodes to the node-red runtime, they get installed in this "userDir" under node_modules (e.g. ~/.node-red/modules) and not in the src packages/node_modules )
NOTE: "userDir" can be spcified by a command line parameter of -u path (see documentation for this an more)
To clarify what is happening here, this is a monorepo that contains the 7 separate npm modules that make up Node-RED.
By having them under a node_modules directory in the src repo, it allows them to find each other when using require - as it ensures they are on the node search path.
Thanks for clarifying that. Though by "node packages" I meant node.js/npm packages, common terms seem to be causing confusion here.
But that brings up one point in my mind though: are workflows and node-red nodes user specific? Why do we need a "userDir" directory to install node-red nodes? Ideally the nodes should be visible to all users so they can use them in their workflows, isn't it? By user I mean the end user who is creating the workflows to automate their work and not node-red developer who is using node-red to create a custom workflow framework.
Node-RED is a single tenant runtime. It only runs one set of flows. You can have multiple users collaborate on those flows, but ultimately it's the same set of flows they are working on.
You cannot have different nodes installed for different users.
the term userDir is from a linux server perspective... it is the user that the Node-RED server process is running under. You can run multiple instances of Node-RED on a server - each with it's own userDir, port number, and set of flows... but as Nick pointed out - each instance is separate from the others and runs one set of flows.
Just adding to that, you can, of course, run multiple Node-RED instances from the same Node-RED installed package with different userDir folders so the naming does make sense anyway.