Objectid is not compatible with my version of node

Trying to migrate to new server, and when I did, I upgraded node-red to version 2.0.5, and now I am having some major issues.

Flows won't deploy due to missing node types, and I keep getting errors installing some nodes:

2021-08-08T02:57:09.697Z Install : node-red-contrib-objectid 0.7.2

2021-08-08T02:57:11.434Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-objectid@0.7.2
2021-08-08T02:57:13.142Z [err] npm
2021-08-08T02:57:13.143Z [err]  
2021-08-08T02:57:13.143Z [err] WARN
2021-08-08T02:57:13.143Z [err]  
2021-08-08T02:57:13.143Z [err] old lockfile
2021-08-08T02:57:13.143Z [err]  
2021-08-08T02:57:13.143Z [err] npm
2021-08-08T02:57:13.143Z [err]  
2021-08-08T02:57:13.143Z [err] WARN
2021-08-08T02:57:13.143Z [err]  
2021-08-08T02:57:13.146Z [err] old lockfile
2021-08-08T02:57:13.146Z [err]  The package-lock.json file was created with an old version of npm,
2021-08-08T02:57:13.146Z [err] npm
2021-08-08T02:57:13.146Z [err]  
2021-08-08T02:57:13.146Z [err] WARN
2021-08-08T02:57:13.146Z [err]  
2021-08-08T02:57:13.146Z [err] old lockfile
2021-08-08T02:57:13.146Z [err]  so supplemental metadata must be fetched from the registry.
2021-08-08T02:57:13.146Z [err] npm
2021-08-08T02:57:13.146Z [err]  
2021-08-08T02:57:13.146Z [err] WARN
2021-08-08T02:57:13.146Z [err]  
2021-08-08T02:57:13.147Z [err] old lockfile
2021-08-08T02:57:13.147Z [err]  
2021-08-08T02:57:13.147Z [err] npm
2021-08-08T02:57:13.147Z [err]  
2021-08-08T02:57:13.147Z [err] WARN
2021-08-08T02:57:13.147Z [err]  
2021-08-08T02:57:13.147Z [err] old lockfile
2021-08-08T02:57:13.147Z [err]  This is a one-time fix-up, please be patient...
2021-08-08T02:57:13.147Z [err] npm
2021-08-08T02:57:13.147Z [err]  
2021-08-08T02:57:13.147Z [err] WARN
2021-08-08T02:57:13.147Z [err]  
2021-08-08T02:57:13.147Z [err] old lockfile
2021-08-08T02:57:13.152Z [err]  
2021-08-08T02:57:54.253Z [err] npm
2021-08-08T02:57:54.254Z [err]  
2021-08-08T02:57:54.254Z [err] ERR!
2021-08-08T02:57:54.254Z [err]  
2021-08-08T02:57:54.254Z [err] code
2021-08-08T02:57:54.254Z [err]  EBADENGINE
2021-08-08T02:57:54.256Z [err] npm
2021-08-08T02:57:54.256Z [err]  
2021-08-08T02:57:54.256Z [err] ERR!
2021-08-08T02:57:54.256Z [err]  
2021-08-08T02:57:54.256Z [err] engine
2021-08-08T02:57:54.256Z [err]  Unsupported engine
2021-08-08T02:57:54.256Z [err] npm
2021-08-08T02:57:54.256Z [err]  
2021-08-08T02:57:54.256Z [err] ERR!
2021-08-08T02:57:54.256Z [err]  
2021-08-08T02:57:54.256Z [err] engine
2021-08-08T02:57:54.256Z [err]  Not compatible with your version of node/npm: node-red-contrib-objectid@0.7.2
2021-08-08T02:57:54.257Z [err] npm
2021-08-08T02:57:54.257Z [err]  
2021-08-08T02:57:54.257Z [err] ERR!
2021-08-08T02:57:54.257Z [err]  
2021-08-08T02:57:54.257Z [err] notsup
2021-08-08T02:57:54.257Z [err]  Not compatible with your version of node/npm: node-red-contrib-objectid@0.7.2
2021-08-08T02:57:54.257Z [err] npm
2021-08-08T02:57:54.257Z [err]  
2021-08-08T02:57:54.257Z [err] ERR!
2021-08-08T02:57:54.257Z [err]  
2021-08-08T02:57:54.257Z [err] notsup
2021-08-08T02:57:54.257Z [err]  Required: {"node":"^0.12.7"}
2021-08-08T02:57:54.257Z [err] npm
2021-08-08T02:57:54.257Z [err]  
2021-08-08T02:57:54.257Z [err] ERR!
2021-08-08T02:57:54.257Z [err]  
2021-08-08T02:57:54.258Z [err] notsup
2021-08-08T02:57:54.258Z [err]  Actual:   {"npm":"7.20.3","node":"v16.6.1"}
2021-08-08T02:57:54.271Z [err] 
2021-08-08T02:57:54.271Z [err] npm
2021-08-08T02:57:54.271Z [err]  
2021-08-08T02:57:54.271Z [err] ERR!
2021-08-08T02:57:54.271Z [err]  A complete log of this run can be found in:
2021-08-08T02:57:54.271Z [err] npm
2021-08-08T02:57:54.272Z [err]  
2021-08-08T02:57:54.272Z [err] ERR!
2021-08-08T02:57:54.272Z [err]      /home/sidthetech/.npm/_logs/2021-08-08T02_57_54_260Z-debug.log
2021-08-08T02:57:54.281Z rc=1

I am using node version 16.x.x and I understand that the node probably won't work on the new version. This was used in my old flows when querying mongodb ...

I really want to use the latest version of node-red and hopefully node.

Any suggestions to get this going? I imagine there are other node types that are probably outdated as well.

You would need to contact the author of that node to see if they are willing to update it. Or stop using it.

Maybe this fork will work?

1 Like

@mrSidX im guessing you were using that node-red-contrib-objectid because somewhere in your flow you are using a Function node to prepare a query for the Mongodb database? and you wanted to query based on the _id and the id in mongo is a special object which is not exposed to Function nodes. Is this correct ?

maybe there is a way around it without using a seperate node just to create that ObjectId.

with the new versions of Node-red you have something called functionExternalModules that gives you the ability to load external modules in your Function nodes. You can read how to set that up here

Now with that setup you can use the mongodb driver module in the Setup tab of your Function node.

image

and in code you can use mongo's ObjectId like this ObjectId("6001215079d9790bac657abb")
below is just an example of my temperatures collection test db

let ObjectId = mongodb.ObjectId

msg.collection = "temperatures"
msg.operation = "aggregate"

msg.payload = [
   //{$unwind: "$temps"},
   { "$match": { "_id": ObjectId("6001215079d9790bac657abb") } },
   { "$sort": { dt: -1 } },
   //{"$limit": 2},
   //{"$skip": 0}
];

return msg;
1 Like

You are absolutely 100% on point.

I have many end-points/flows to modify in this case, and
I foresee a few works arounds...

-Implement the functionExternalModules as you suggest to have the Mongo Object accessible to the function node, and hand change all the endpoints/flows in function code to accommodate this work-around,

-Do the said work-around above, but have a Universal SubFlow that will act like the existing objectid

-Or : Just modify the objectid node to be compatible with the new node versions. (ideal for my case)

Wondering how involved it might be to update the node-type to something similar that will work.
Maybe I can contact the developer?
Maybe I can modify the existing package to play nice?

I'm not a deep node-red-node developer by any means, so maybe the work-around will have to suffice.

when you say

how many are there ? :wink:
its going to be a hassle to change all the functions and the functionExternalModules workaround needs a couple of steps but at least you wont be depended on a node for something simple, since you are already using a function before your db. Its up to you.

By the way i tried installing both nodes also on my system (node v14) and both fail and require a 5 year old nodejs. The github link of node-red-contrib-objectid is dead and the package deprecated so i dont know how easy it is to contact the developer.

agreed... There are quite a few endpoints to modify, as I have a user system built in, utilizing the database, and various other flows that query with the DB
I have a "middleware" type of Subflow where every endpoint visited gets client token/session and queries the db for that associated user, checks if it's a valid user, and returns what permissions and other user related data.

so what exactly were you passing into the node-red-contrib-objectid ?
what was the msg like ?

according to the node's page
you needed the string _id to be either
msg.payload._id = "572dbc06f307c8682045c55c"
or
msg.payload.uuid = "572dbc06f307c8682045c55c"

Create a function that with the use of functionExternalModules replicates what node-red-contrib-objectid did.

for Example

let ObjectId = mongodb.ObjectId

try {
    msg.payload._id = ObjectId(msg.payload._id)
    return msg;
} catch (error) {
    node.warn(error);
};

and copy paste and replace all object id nodes with your own function node
try it on one endpoint first for test

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.