I am new to node-red. I tried the example provided in the video and now when I click the inject node. Node-Red just shutdown. I included the workflow below.
[
{
"id": "709799acea2e533f",
"type": "tab",
"label": "Flow 5",
"disabled": false,
"info": "",
"env": []
},
{
"id": "f6fc50ee2b18a97a",
"type": "inject",
"z": "709799acea2e533f",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 140,
"wires": [
[
"d074323f939f8f39"
]
]
},
{
"id": "6d65cc020fa74fca",
"type": "function",
"z": "709799acea2e533f",
"name": "paddthembaby",
"func": "//import * as fs from 'fs';\n//import PDFMerger from \"file:///D:/Program%20Files/nodejs/node_modules/pdf-merger-js/index.js\";\n//import pdf from \"file:///D:/Program%20Files/nodejs/node_modules/pdf-page-counter/index.js\";\n\nvar fs = fs;\nvar merger = new pdfMerger();\n\nconst pathtoblank = 'E:/PP_Processes/HR/BlankPdfPage/Blank.pdf';\n\nvar pathtopdf = msg.PathToFile;\nvar pathtooutput = msg.PathToOutput;\n\n(async () => {\n let dataBuffer = fs.readFileSync(pathtopdf);\n console.log(pathtopdf);\n pdf(dataBuffer).then(async function (data) {\n // number of pages\n console.log(data.numpages);\n await merger.add(pathtopdf);\n if (data.numpages % 2 > 0) {\n await merger.add(pathtoblank);\n }\n await merger.save(pathtooutput);\n })\n})();",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "\n",
"finalize": "",
"libs": [
{
"var": "fs",
"module": "fs"
},
{
"var": "pdfMerger",
"module": "pdf-merger-js"
},
{
"var": "pdf",
"module": "pdf-page-counter"
}
],
"x": 920,
"y": 180,
"wires": [
[
"93892fe06ea34413"
]
]
},
{
"id": "bd2f9238b82802c8",
"type": "function",
"z": "709799acea2e533f",
"name": "function 56",
"func": "var today = new Date();\nvar dd = String(today.getDate()).padStart(2, '0');\nvar mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!\nvar yyyy = today.getFullYear();\n\nmsg.PathToFile = msg.payload\nvar backslash = '\\\\';\nmsg.filename = msg.payload.slice(msg.payload.lastIndexOf(\"\\\\\")+1);\nmsg.PathToBackup = \"E:\\\\PP_DATA_COPY_EXCH\\\\Human_Resources\\\\Posters\\\\Archive\\\\Backup\" + \"\\\\\" + yyyy + \"\\\\\" + mm + \"\\\\\" + dd + \"\\\\\" + msg.filename;\nmsg.PathtoOutput = \"E:\\\\PP_DATA_COPY_EXCH\\\\Human_Resources\\\\Posters\\\\Padded\\\\\" + msg.filename;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 670,
"y": 140,
"wires": [
[
"8d1289164f51b01f",
"6d65cc020fa74fca"
]
]
},
{
"id": "d074323f939f8f39",
"type": "olfnf-folder-listing",
"z": "709799acea2e533f",
"folder": "E:\\PP_DATA_COPY_EXCH\\Human_Resources\\Posters\\In",
"folder_type": "str",
"subfolder": false,
"ignoreempty": true,
"masks": "*.*",
"masksregex": false,
"name": "",
"x": 330,
"y": 140,
"wires": [
[
"42b75d085f92e9e9",
"6876cb2dac7f5af8"
]
]
},
{
"id": "42b75d085f92e9e9",
"type": "debug",
"z": "709799acea2e533f",
"name": "debug 25",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 430,
"y": 240,
"wires": []
},
{
"id": "8d1289164f51b01f",
"type": "debug",
"z": "709799acea2e533f",
"name": "debug 26",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 700,
"y": 80,
"wires": []
},
{
"id": "6876cb2dac7f5af8",
"type": "split",
"z": "709799acea2e533f",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 510,
"y": 140,
"wires": [
[
"bd2f9238b82802c8"
]
]
},
{
"id": "93892fe06ea34413",
"type": "debug",
"z": "709799acea2e533f",
"name": "debug 28",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1160,
"y": 120,
"wires": []
}
]
Any help with this would be greatly appreciated.