Sort out node installed globally

Having recently installed an instance of @TotallyInformation alternate install on my Win 10 machine, I noticed that the Blocky node (node-red-contrib-blockly) came with it.

Julian has pointed out to me that he doesn't supply any nodes pre-installed and that I probably installed it globally in the past

Since I was a beta tester, this is quite likely

I'm wondering what is the best way to resolve this situtation without mucking up my main standard Node-RED install running on same Win machine

Its complicated by the fact that I'm running V1.2.0 of the node from github and not the standard npm 1.1.0 version

There is no magic to npm modules.

If you remove global modules but still need to use one, you would need to install locally. Same as you are doing with Node-RED itself.

Modules are contained by a folder with an entry in a package.json

Bottom line is that you should just do a npm remove -g node-red-contrib-blockly, restart node-red and see if the blockly node still turns up.

If you really get stuck, you can search your drive(s) for node_module folders and find any sub-folders called node-red-contrib-blockly and just delete them.

If you break something, you can just install the node again.

1 Like

well npm is dark arts to me :slight_smile:

i did the global un-install but the node didn't disappear from the alternate install so I'm now hunting it down thru my file system but I've a feeling this is going to take some time :slight_smile:

Still searching 3 hours later...... :slight_smile:

In the meantime, if I could ask a followup question picking up on "There is no magic to npm modules."

If I install nodes via palette in alternate install, why do they put into ./data/node-modules rather than into ./node-modules like the standard NR install does?

OK, so it looks like you have some blockly bits left in your global install but not the node.

You have the node installed in your default userDir (~/.node-red) so if you are using a globally installed copy of Node-RED, that is fine.

However, if you are using a locally installed version - like my installer creates - you need to also install it in the data folder of that installation which is the userDir that you give to the Node-RED instance. Obviously, the easiest way to get that right is to use the palette manager.

1 Like

Eureka :slight_smile:

Deleted that folder, restarted my alternate instance, browser cache empty and its gone :slight_smile:

image

And my main NR instance is fine

:slight_smile:

2 Likes

Resurrecting this issue with specific example as having testing issues my simpletime node dev

AFAIU a standard node red install sticks all palette contrib nodes into ~/.node-red/node_modules

Alternate install sticks them into ~/.nrxxxx/data/node-modules

Which is different but works with no problem if just using palette installs

BUT I'd like to test an install from a github dev fork so i use

npm install --save https://github.com/cymplecy/node-red-contrib-simpletime.git#tickboxes

That sticks the github version into ~./nrxxxx/node_modules

But the alternate install continues to use the original palette version (2.9.1 in this case vs 2.9.6 for my github version)

How can I square this circle so that my github 2.9.6 version overwrites the palette 2.9.1 version?

If the palette is installing to the "wrong" place, it is because your userDir isn't pointed where you think it is for the running instance. The palette should always be installing to the userDir (as defined in your startup script) and your manual installs should be in the same folder.

Easy enough to check. The package.json file in the userDir will show you whether you have that module installed from GitHub or npm. You could even create a flow to import it and view it. Just note that, if running from the alt. installer, the current working directory in Node-RED will be wherever you installed Node-RED, it won't be the userDir.

Also worth noting that the root folder that the alt. installer uses has it's own package.json file of course since that is where the Node-RED package is installed. You can install Node-RED custom node packages to that folder as well - but then you cannot manage those from the palette and it gets very confusing so best avoided.

One last point - you did restart Node-RED after installing manually? Installing from the palette often gets away without needing to restart but that doesn't work when installing manually.

I'm simply following your instructions when starting :slight_smile:

Yep, so that will make the userDir ./data and the palette will install to that folder.

The start script should be:

node node_modules/node-red/red.js --userDir ./data

But in the package.json for the data folder, start should be:

cd .. && node node_modules/node-red/red.js --userDir ./data

or alternatively:

node ../node_modules/node-red/red.js --userDir ../data

I think, I've not actually tried that one - you could make everything absolute references of course and then you might save some confusion. Though it wouldn't then work without tweaking if you ever move it. The advantage of the settings is that they don't need to take account of the location of the parent folder. and even if you rename that folder or copy it somewhere, everything still works as expected.

All agreed with that - that's what happens :slight_smile:

I think my question is - how do I make my github installs overwrite that one rather than get put into ~.nrxxxx/node_modules?

cd ~/.nrxxxx
npm install --save https://github.com/cymplecy/node-red-contrib-simpletime.git#tickboxes

I keep everything on my dev PC under the c:\src folder:

cd c:\src\nr2
# This is where node-red was installed
cd data
# This is the userDir
npm install --save https://github.com/cymplecy/node-red-contrib-simpletime.git#tickboxes

On my home server everything is under my normal login and Node-RED lives in ~\nrlive, it looks like this:

cd ~\nrlive
# This is where node-red was installed
cd data
# This is the userDir
npm install --save https://github.com/cymplecy/node-red-contrib-simpletime.git#tickboxes

This is back to square one :slight_smile:

That's what I'm doing
[edit about 5 times now !] I'm in /home/pi/.nr18884_simpletime folder in this instance when I issue this command[/edit]

Is /home/pi/.nr18884_simpletime where you have Node-RED installed or is it the userDir you are using?

If the latter, that is exactly where you should be and you will end up with a folder /home/pi/.nr18884_simpletime/node_modules/node-red-contrib-simpletime/ and an entry in /home/pi/.nr18884_simpletime/package.json showing simpletime is a dependency and is using the GitHub version.

Manage Palette will show the node and whatever version number is in the package.json of the installed version as in this example of the dev version of uibuilder:

image

It doesn't show that it comes from GitHub.

By the way, when installing from GitHub, you can simply do:

npm install cymplecy/node-red-contrib-simpletime#tickboxes

npm is already GitHub aware & --save is the default anyway.

1 Like

There seems to be total confusion between us as to what is going on :slight_smile:

I'm going to start again and record a video of each step to show what happens with me

Hopefully, that will either show you my issue or show me what I'm doing wrong :slight_smile:

PS - I'm off to dig some holes in the garden for trees and hedge as a displacement activity :slight_smile:

Bangs head against wall :laughing:

OK - I've given up trying to document what is going on as my recorded gif is unreadable!

I turned to googling and came up with the npm --prefix flag

so in my new test /home/pi/nrtest folder (having previously installed simple time using palette and got 2.9.1) I did this

image

and it updated the existing /home/pi/nrtest/data/node_modules/node-red-contrib-simpletime files to v2.9.6 and updated what it thinks it is installed in the palette

Genuinely, I'm at a loss as to what is happening for you.

The alt. installer actually works in a more node.js/npm way than Node-RED's "recommended" installation and I've never had any issues with it. Though admittedly I always keep the userDir inside the main Node-RED dir since that can then all be moved/copied together.

--prefix is meant to be used if you want to install something to a folder other than the folder you are currently in.

From your command image. It looks to me as though you are in the folder where you installed Node-RED itself but you are trying to install the module to the data subfolder. Not sure why you haven't just cd'd to the subfolder and done a normal install from there?

Assuming you are starting node-red from the ~/nrtest folder with node node_modules/node-red/red.js --userDir ./data then everything would be in the right place anyway.

AFAICT this is just a communication breakdown between us.

The main issue is that you speak npm fluently and I only know 3 words :slight_smile:

I think it needs somebody else to bring us together round the table :slight_smile:

Anyway - I currently have got both palette installs and npm github installs going into the same folder - so at least I can use it for testing which is my goal :slight_smile:

1 Like

Apologies - having had a sleep and doing a clean install routine a few times I find I don't need the --prefix if I cd into the data folder e.g ~/nrtest/data before doing the npm install.

It does overwrite the previous contrib node install that was installed using palette.

(As previous found out - it doesn't work if I issue the npm install from the basefolder e.g ~/nrtest)

So I'm sorted - apologies again

1 Like