Keep getting the error "Cannot find module 'luxon'" message when working with dates

Describe the problem/error/question

I’ve tried several instances with date coming from Google Sheets. I always receive in format dd-MM-yyyy, dd-M-yyyy, d-MM-yyyy or d-M-yyy. Some are recognized but the date/time node is not working properly and can’t detect the dates. And when I try to use luxon I always get the message: Cannot find module ‘Luxon’.

What is the error message (if any)?

Cannot find module ‘Luxon’

Please share your workflow

{
“nodes”: [
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
0,
0
],
“id”: “80a2e158-7bbc-48b2-9891-5095c15875b8”,
“name”: “When clicking ‘Test workflow’”
},
{
“parameters”: {
“jsCode”: “const { DateTime } = require(‘luxon’); \n\nfor (const item of $input.all()) {\n const inputDateString = item.json.MyDate;\n \n if (inputDateString) {\n const parsedDate = DateTime.fromFormat(inputDateString, ‘dd-MM-yyyy’); // Gebruik correct formaat met hyphens\n \n if (parsedDate.isValid) {\n item.json.formattedDate = parsedDate.toFormat(‘yyyy-MM-dd’);\n } else {\n item.json.formattedDate = Error: Could not parse '${inputDateString}';\n }\n } else {\n item.json.formattedDate = null;\n }\n}\n\nreturn $input.all();”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
220,
0
],
“id”: “03cc232d-bafb-43c8-9060-f5b934246ac8”,
“name”: “Code”
}
],
“connections”: {
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {
“When clicking ‘Test workflow’”: [
{
“MyDate”: “05-03-2005”
}
]
},
“meta”: {
“instanceId”: “20e806f6fb792b04b2595efc7ffd0f890e39c18d70537c766e79cf04298c5d80”
}
}

Share the output returned by the last node

VMError: Cannot find module ‘luxon’
at Resolver.resolveFull (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/resolver.js:126:9)
at Resolver.resolve (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/resolver.js:121:15)
at resolve (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:317:21)
at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)
at requireImpl (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/setup-node-sandbox.js:90:19)
at require (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/setup-node-sandbox.js:171:10)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:1:119
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Code:20:2
at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/bridge.js:490:11)
at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/@n8n/vm2/lib/nodevm.js:497:23)


## Information on your n8n setup
- **n8n version:** 1.93
- **Database (default: SQLite):** don't use any
- **n8n EXECUTIONS_PROCESS setting (default: own, main):** basic from fresh install
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** selfhosted docker on own pc
- **Operating system:** Windows 11 64

Hi, I can help with this. The reason for this error is that the module in this case isn’t installed.

I recommend to check this thread below which explains in detail on how to install custom ones.

Thnx for the reply! Got another reply as well. With both solutions it worked!

1 Like

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