{"record":{"id":"576798b9d856eb2f","repo":"n8n-io/n8n","slug":"code-node-forbidden-import","errorCode":"CODE_NODE_FORBIDDEN_IMPORT","errorMessage":"${namePrefix}Code node imports a module unavailable in the sandbox (luxon, openai, langchain, …). Use JavaScript `Date`/`Intl`, `$now`/`$today`, existing workflow data, or dedicated AI nodes instead.","messagePattern":"(.+?)Code node imports a module unavailable in the sandbox \\(luxon, openai, langchain, …\\)\\. Use JavaScript `Date`/`Intl`, `\\$now`/`\\$today`, existing workflow data, or dedicated AI nodes instead\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/@n8n/workflow-sdk/src/lint/code-node/js.ts","lineNumber":180,"sourceCode":"\tif (sawNetwork) {\n\t\tissues.push(\n\t\t\tlintIssue({\n\t\t\t\tcode: 'CODE_NODE_NETWORK_CALL',\n\t\t\t\tmessage:\n\t\t\t\t\t`${namePrefix}Code node calls fetch/axios/XMLHttpRequest or requires an HTTP module. ` +\n\t\t\t\t\t'Code nodes have no network access at runtime — make the HTTP/API call with an HTTP Request node ' +\n\t\t\t\t\t'and transform its output in the Code node instead.',\n\t\t\t\tlintTarget: 'jsCode',\n\t\t\t\tnodeName: options.nodeName,\n\t\t\t\tparameterPath: 'jsCode',\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (sawForbiddenImport) {\n\t\tissues.push(\n\t\t\tlintIssue({\n\t\t\t\tcode: 'CODE_NODE_FORBIDDEN_IMPORT',\n\t\t\t\tmessage:\n\t\t\t\t\t`${namePrefix}Code node imports a module unavailable in the sandbox (luxon, openai, langchain, …). ` +\n\t\t\t\t\t'Use JavaScript `Date`/`Intl`, `$now`/`$today`, existing workflow data, or dedicated AI nodes instead.',\n\t\t\t\tlintTarget: 'jsCode',\n\t\t\t\tnodeName: options.nodeName,\n\t\t\t\tparameterPath: 'jsCode',\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (options.mode === 'runOnceForEachItem' && disallowedInputMethod !== undefined) {\n\t\tissues.push(\n\t\t\tlintIssue({\n\t\t\t\tcode: 'CODE_MODE_API_MISUSE',\n\t\t\t\tmessage:\n\t\t\t\t\t`${namePrefix}uses mode: 'runOnceForEachItem' but calls $input.${disallowedInputMethod}(). ` +\n\t\t\t\t\t`$input.${disallowedInputMethod}() is only available in runOnceForAllItems (the default). ` +\n\t\t\t\t\t'Switch mode to runOnceForAllItems, or use $input.item / $json for per-item work.',","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/lint/code-node/js.ts#L162-L198","documentation":"CODE_NODE_FORBIDDEN_IMPORT is a lint issue. lintJsCode() flags imports/requires whose specifier starts with luxon, openai, @openai/, langchain, or @langchain/ — modules that are not available in the Code node sandbox. The message points to native Date/Intl, $now/$today, workflow data, or dedicated AI nodes instead.","triggerScenarios":"import { DateTime } from 'luxon', require('openai'), import OpenAI from 'openai', import { ChatOpenAI } from '@langchain/openai', or await import('langchain').","commonSituations":"LLM adds a date library for formatting; agent reaches for the OpenAI SDK inside a Code node instead of an AI node; porting LangChain example code.","solutions":["Replace luxon with native Date/Intl or the $now/$today expression variables.","Move OpenAI/LangChain usage to the dedicated AI/Agent nodes instead of importing inside a Code node.","Remove the import and operate on existing workflow data."],"exampleFix":"// before (Code node jsCode)\nimport { DateTime } from 'luxon';\nreturn DateTime.now().toISO();\n// after\nreturn new Date().toISOString();","handlingStrategy":"validation","validationCode":"import { lintJsCode } from '@n8n/workflow-sdk/lint/code-node/js';\nconst issues = lintJsCode(jsCode, { mode });\nif (issues.some((i) => i.code === 'CODE_NODE_FORBIDDEN_IMPORT')) {\n  throw new Error('jsCode imports luxon/openai/langchain; use native Date/Intl or AI nodes.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use native Date/Intl and $now/$today instead of luxon.","Use dedicated AI/Agent nodes instead of importing openai/langchain in a Code node.","Run lintJsCode on every generated Code node before persisting."],"tags":["lint","code-node","imports","sdk"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}