n8n-io/n8n · warning
CODE_NODE_FORBIDDEN_IMPORT
CODE_NODE_FORBIDDEN_IMPORT
Error message
${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. What it means
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.
Source
Thrown at packages/@n8n/workflow-sdk/src/lint/code-node/js.ts:180
if (sawNetwork) {
issues.push(
lintIssue({
code: 'CODE_NODE_NETWORK_CALL',
message:
`${namePrefix}Code node calls fetch/axios/XMLHttpRequest or requires an HTTP module. ` +
'Code nodes have no network access at runtime — make the HTTP/API call with an HTTP Request node ' +
'and transform its output in the Code node instead.',
lintTarget: 'jsCode',
nodeName: options.nodeName,
parameterPath: 'jsCode',
}),
);
}
if (sawForbiddenImport) {
issues.push(
lintIssue({
code: 'CODE_NODE_FORBIDDEN_IMPORT',
message:
`${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.',
lintTarget: 'jsCode',
nodeName: options.nodeName,
parameterPath: 'jsCode',
}),
);
}
if (options.mode === 'runOnceForEachItem' && disallowedInputMethod !== undefined) {
issues.push(
lintIssue({
code: 'CODE_MODE_API_MISUSE',
message:
`${namePrefix}uses mode: 'runOnceForEachItem' but calls $input.${disallowedInputMethod}(). ` +
`$input.${disallowedInputMethod}() is only available in runOnceForAllItems (the default). ` +
'Switch mode to runOnceForAllItems, or use $input.item / $json for per-item work.',View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before (Code node jsCode)
import { DateTime } from 'luxon';
return DateTime.now().toISO();
// after
return new Date().toISOString(); Defensive patterns
Strategy: validation
Validate before calling
import { lintJsCode } from '@n8n/workflow-sdk/lint/code-node/js';
const issues = lintJsCode(jsCode, { mode });
if (issues.some((i) => i.code === 'CODE_NODE_FORBIDDEN_IMPORT')) {
throw new Error('jsCode imports luxon/openai/langchain; use native Date/Intl or AI nodes.');
} Prevention
- 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.
When it happens
Trigger: import { DateTime } from 'luxon', require('openai'), import OpenAI from 'openai', import { ChatOpenAI } from '@langchain/openai', or await import('langchain').
Common situations: 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.
Related errors
- CODE_NODE_NETWORK_CALL
- CODE_MODE_API_MISUSE
- CODE_NESTED_TEMPLATE_LITERAL
- CODE_NODE_NETWORK_CALL
- SDK_AS_CONST
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/576798b9d856eb2f.
Report an issue: GitHub.