Sorry if the question could be stupid, but I don't know how to solve this.
I recently upgraded my OS to new Lubuntu version 20.04 and I lost my files.
I re-installed Node-RED and now I don't have 1.0.5, but 1.0.6 version.
The problem is that now when I use my custom node that use MQTT javascript library, I get the error : cannot find module mqtt.
My node-red was installed into /usr/local/lib/node_modules/node-red/ and the .nod-red folder into /home/USER.
Why now when I use a custom node, I get this error? Before these changes all worked perfectly.
EDIT: Also if I install mqtt globally, I get the same error.
/home/edoardottt/Desktop/my-Node-RED/custom/node-red-contrib-custom-folder-example
This is the location, before starting node-red, i type npm install {this_path} inside .node-red folder and the output is ok, all right.
No, there isn't the dependency... but in node-red1.0.5 it worked. I'm adding this.
I notice that node red pulls in version 2.18.8, I don't know whether it is significant that it does not use v3. Have you now got multiple versions installed? What does npm list -g mqtt
show? However Nick is right. You should specify a dependency in your custom node, then it would install the version you require automatically.
Now it's working. But I think i'm doing something wrong. Now in every custom node it downloads a big node_modules folder...How is it possible? It's a waste of space. If it depends on a specific module why not have a single point of shared node_modules?
Obviously, I downloaded mqtt with global mode enabled, but why it has to download the same module n times?
How did you install nodejs and npm? npm used to do that I think, but now it flattens things out so it shouldn't happen. I think.
What version of npm are you running? npm -v
Actually 12.x is the newest LTS version and the bleeding edge (not recommended) is 13.x, but 10.x is ok. I don't know whether the versions from the Lubuntu repository are ok, I use the recommended install script for Ubuntu which installs from the nodesource repository. However I have no reason to think that the versions you have should not be ok. Someone more knowledgeable would have to comment.