CLI Commands
Relevant source files
The following files were used as context for generating this wiki page:
- packages/@n8n/node-cli/package.json
- packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.json
- packages/frontend/editor-ui/src/constants.ts
- packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json
- packages/nodes-base/nodes/HtmlExtract/test/workflow.dotNotation.json
- packages/nodes-base/nodes/Webhook/Webhook.node.json
The n8n ecosystem provides several touchpoints with Command-Line Interfaces (CLIs), catering to different user needs. This includes executing shell commands directly within a workflow, a dedicated CLI for community node development, and interactions with standard CLI tools like cURL. These capabilities allow for advanced automation, programmatic control over the n8n instance, and streamlined development of custom extensions.
The Execute Command Node
One of the most direct ways to interact with a command-line environment is through the Execute Command node. This node allows you to run arbitrary terminal commands on the server that is hosting the n8n instance.
Its primary purpose is to bridge n8n workflows with external scripts or system commands. According to its definition, it is "useful for executing a shell script or interacting with your n8n instance programmatically via the CLI." This means you can use it to run scripts, manage files, or even call the main n8n CLI to perform administrative tasks from within a workflow.
The node is categorized under "Development" and "Core Nodes" and has several aliases, including Shell, Command, OS, and Bash, reflecting its function.
Sources: packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.json:2-17
The following diagram illustrates the conceptual flow of using the Execute Command node within a workflow.
Community Node Development CLI (@n8n/node-cli)
For developers looking to extend n8n with custom nodes, the project provides a dedicated command-line tool: @n8n/node-cli. This package is described as the "Official CLI for developing community nodes for n8n".
The CLI is built using the @oclif/core framework and provides the n8n-node executable. It is designed to scaffold, build, and manage community node packages.
Sources: packages/@n8n/node-cli/package.json:2-4, 35
Key Components and Dependencies
The CLI tool relies on several key dependencies to provide its functionality. The diagram below shows the main components.
Configuration and Scripts
The package.json for @n8n/node-cli defines its structure and available commands. The oclif configuration specifies how the CLI discovers and runs commands.
"oclif": {
"bin": "n8n-node",
"commands": {
"strategy": "explicit",
"target": "./dist/index.js",
"identifier": "commands"
},
"topicSeparator": " "
}
Sources: packages/@n8n/node-cli/package.json:26-33
The package also includes several npm scripts for development and maintenance of the CLI tool itself.
| Script | Description |
|---|---|
clean | Removes the dist and .turbo directories. |
typecheck | Runs the TypeScript compiler to check for type errors. |
dev | Starts the TypeScript compiler in watch mode for development. |
build | Compiles the TypeScript source code to JavaScript. |
test | Runs the test suite using vitest. |
start | Executes the CLI tool directly. |
| Sources: packages/@n8n/node-cli/package.json:13-22 |
Interacting with n8n via External CLI Tools
cURL Integration
n8n provides a user-friendly way to create nodes from cURL commands, a staple of command-line HTTP interaction. The UI includes a modal, identified by the key IMPORT_CURL_MODAL_KEY, for this purpose. This feature simplifies the process of translating an API call from a cURL command into an HttpRequest node. The HttpRequest node itself includes cURL as an alias, highlighting this connection.
Sources: packages/frontend/editor-ui/src/constants.ts:72, packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json:98
The following diagram shows the sequence of importing a cURL command.
While powerful, the cURL import feature does not support all protocols. The following table lists the explicitly unsupported protocols.
| Unsupported Protocols |
|---|
| ftp |
| ftps |
| dict |
| imap |
| imaps |
| ldap |
| ldaps |
| mqtt |
| pop |
| pop3s |
| rtmp |
| rtsp |
| scp |
| sftp |
| smb |
| smbs |
| smtp |
| smtps |
| telnet |
| tftp |
| Sources: packages/frontend/editor-ui/src/constants.ts:443-465 |