Persian-date library

hi , i need to design a calendar in Persian to schedule by our origin calendar , but functions cant resolve it
at first I've installed library (npm install persian-date) after that in node red by function node i tried to use it :

var persianDate = require('persian-date');
var now = new persianDate();
msg.payload = now.format('YYYY/MM/DD - HH:mm:ss');
return msg;

but i get this error :ReferenceError: require is not defined (line 1, col 19)

You can't use require in function nodes.

you need to register its use in the setup tab of the function node.

Then you can do:

const now = new persianDate();
msg.payload = now.format('YYYY/MM/DD - HH:mm:ss');
return msg;

Also you dont need to install the module your self, the setup tab will install the module for you.

thanks a lot for your quick response

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