Npm, versioning and palette manager confusions

Using node-red 1.3.1 I find that if I install a node (any node) using npm on the command line then it puts into package.json a dependency of the form "^1.2.3" which means, I believe, that the version must be at least 1.2.3 but must be less than 2.0.0.
If I install the same node using the palette manager then the entry is "~1.2.3" which means that the version must be at least 1.2.3 but must be less than 1.3.0.

I assumed that this was the reason that the palette manager was not showing me an update to the node as the update was >1.2.3. However the plot thickens further because I found that having edited package.json and change the ~ to ^, restarted node-red, cleared the browser cache and doing a full browser refresh that the palette manager still would not provide the update, so now I am very confused.

In this thread @scargill had exactly this problem with node-red-node-sqlite and I found that one of my systems was not providing an update the email node, apparently for the same reason.

Can someone explain how all this is supposed to work? I am tempted to think that there may be a bug in 1.3.1 as I don't remember coming across this issue before, but it may well be me misunderstanding something.

The Palette Manager doesn't use what is in your package.json to filter what it shows. It will always show the latest version available in the catalogue it downloads.

As for the ~ vs ^ - we explicitly tell npm to use the ~ prefix when you run it from the palette manager. The npm default behaviour is to use ^. I can't remember the full history of why we ended up with that choice - or if npm changed their default and we didn't, or what.

Regardless, as I said above, that shouldn't have any bearing on what the palette manager shows you.

Well something is going wrong somewhere. @scargill had (maybe still has) the situation where the serial node was not showing an update and I had the same with the email node. I will check and see whether I still have the situation with other nodes.

If you can share some specifics, we can all check.

Also don't forget npm treats 0.x versions differently. https://docs.npmjs.com/cli/v7/using-npm/semver#caret-ranges-123-025-004

(The recommendation these days is to start at 1.0 - so there is a debate to be had if we should bump the project extra nodes up to at least 1.x in the NR2.0 timeframe even if there is no breaking changes to them .)

2 Likes

These are all out of date and not showing updates
image

node-red 1.3.1
nodejs 10.24.1
npm 6.14.12

What should I look at?

Woah! uibuilder at 1.0.8, that's bonkers, I can't even remember when that was. That certainly doesn't happen on my installations. Let me go double-check though.


No, I have 3 instances of Node-RED running on different devices and none are showing those symptoms. My oldest device is my Pi2, not really anything live running on that now so it doesn't get updated very often. here is what it is showing now:

image

Which looks right to me. The others are updated more regularly and seem up-to-date to me.

Though the Pi2 is showing this for serialport:

image

But I no longer use the serialport on the Pi2 so again, not updated in quite a long time.


uibuilder v1.0.8 is from October 2018!!

This is on a system I use for experimenting. It seems there is still something there using that node from my experiments, that is of no consequence. node-red should be showing me the upgrade option though.

Is the catalogue download done in the server or in the browser? I can't find anything that looks relevant in the trace log or in the browser console. What URL is it? The download cannot be completely failing as it does show upgrades for some nodes, but not others.

Any suggestions as to what I can do to help analyse this?

The catalog is downloaded in the browser when you open the palette manager. Open up the developer tools and switch to the Network tab. Clear the tab to remove any existing entries, then open the palette manager. You should see a request to https://catalogue.nodered.org/catalogue.json?_=1618302136661 (although the timestamp at the end will, of course, be different).

Can you share exactly what you have in your package.json for a specific module thats failing?

On checking I can confirm that absolutely everything is working on the latest NR upgrade with NodeJS 10 - but despite following all advice to date "to the letter" I cannot get the update to NodeJS 12 to work with SQLITE or I2c (the latter is not important as I'm not using I2C in Node-Red, long ago I reverted to controlling displays in Python using the NR EXEC node). This does suggest that Dave's 4-line SQLITE3 upgrade instructions are no longer valid?

Hi Nick

If I go into /home/pi/.node-red/node_modules - and then into node-red-node-sqlite - here are the contents of the package.json file within.

{
  "_args": [
    [
      "node-red-node-sqlite@0.4.3",
      "/home/pi/.node-red"
    ]
  ],
  "_from": "node-red-node-sqlite@0.4.3",
  "_id": "node-red-node-sqlite@0.4.3",
  "_inBundle": false,
  "_integrity": "sha512-SIJlDaRADH92Gh37l9UyMNADBqRkgrK/Eo9XqRfzSk15QIDxX5ujkgmP/MipHC1xrjQL9zH6jst5j5D+srK4Iw==",
  "_location": "/node-red-node-sqlite",
  "_phantomChildren": {},
  "_requested": {
    "type": "version",
    "registry": true,
    "raw": "node-red-node-sqlite@0.4.3",
    "name": "node-red-node-sqlite",
    "escapedName": "node-red-node-sqlite",
    "rawSpec": "0.4.3",
    "saveSpec": null,
    "fetchSpec": "0.4.3"
  },
  "_requiredBy": [
    "/"
  ],
  "_resolved": "https://registry.npmjs.org/node-red-node-sqlite/-/node-red-node-sqlite-0.4.3.tgz",
  "_spec": "0.4.3",
  "_where": "/home/pi/.node-red",
  "author": {
    "name": "Dave Conway-Jones",
    "email": "ceejay@vnet.ibm.com",
    "url": "http://nodered.org"
  },
  "dependencies": {
    "sqlite3": "~4.1.1"
  },
  "description": "A sqlite node for Node-RED",
  "keywords": [
    "node-red",
    "sqlite"
  ],
  "license": "Apache-2.0",
  "name": "node-red-node-sqlite",
  "node-red": {
    "nodes": {
      "sqlite": "sqlite.js"
    }
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/node-red/node-red-nodes/tree/master/storage/sqlite"
  },
  "version": "0.4.3"
}

I think I did use node v12 for some time but I'm on 14 on my live and dev platforms right now. SQLite node is working ok on both.

I am asking about the entry in ~/.node-red/package.json that @Colin was referring to that appeared to be 'blocking' the palette manager from installing the latest.

Did you try manually removing and re-installing node-red-node-sqlite in order to install the latest version?

The download looks fine in the developer console. 1.12 MB. When I fetch it manually in the browser it has the latest versions for the problem nodes.

For node-red-node-email, which is showing 1.8.2 in the palette manager (as in screenshot above) I have
"node-red-node-email": "~1.8.2",

I assume that is the 'nodes' tab. What does it show if you search for that module under the 'install' tab?

Aha, yes. It shows 1.11.0 on the install tab, but 1.8.2 on the Nodes tab, and not offering the upgrade.

Ok, dumb question - how do you upgrade to 14 from 10?

Yes.... I did - absolutely.