Back to N8n

@n8n/create-node

packages/@n8n/create-node/README.md

1.37.27.2 KB
Original Source

@n8n/create-node

A powerful scaffolding tool to quickly create custom n8n community nodes with best practices built-in.

šŸš€ Quick Start

Create a new n8n node in seconds:

bash
npm create @n8n/node@latest # or pnpm/yarn/...

Follow the interactive prompts to configure your node, or specify options directly:

bash
npm create @n8n/node my-awesome-node --template declarative/custom

šŸ“‹ Command Line Options

bash
npm create @n8n/node [NAME] [OPTIONS]

Options

FlagDescription
-f, --forceOverwrite destination folder if it already exists
--skip-installSkip automatic dependency installation
--template <template>Specify which template to use

Available Templates

  • declarative/custom - Start with a minimal declarative node structure
  • declarative/github-issues - GitHub Issues integration example
  • programmatic/example - Full programmatic node with advanced features

šŸŽÆ Interactive Setup

The CLI will guide you through setting up your node:

$ npm create @n8n/node
ā”Œ @n8n/create-node
│
ā—‡ What is your node called?
│ my-awesome-api-node
│
ā—‡ What kind of node are you building?
│ HTTP API
│
ā—‡ What template do you want to use?
│ Start from scratch
│
ā—‡ What's the base URL of the API?
│ https://api.example.com/v1
│
ā—‡ What type of authentication does your API use?
│ API Key
│
ā—‡ Files copied āœ“
│
ā—‡ Dependencies installed āœ“
│
ā—‡ Next Steps ─────────────────────────────────────────────────────────────────────╮
│                                                                                  │
│  cd ./my-awesome-api-node && npm run dev                                       │
│                                                                                  │
│  šŸ“š Documentation: https://docs.n8n.io/integrations/creating-nodes/            │
│  šŸ’¬ Community: https://community.n8n.io                                        │
│                                                                                  │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā•Æ
│
ā”” Created ./my-awesome-api-node ✨

šŸ› ļø Development Workflow

1. Navigate to your project

bash
cd ./my-awesome-api-node

2. Start development server

bash
npm run dev

This command:

  • Starts n8n in development mode on http://localhost:5678
  • Enables hot reload for your node changes
  • Automatically includes your node in the n8n instance
  • Links your node to ~/.n8n-node-cli/.n8n/custom for development
  • Watches for file changes and rebuilds automatically

3. Test your node

  • Open n8n at http://localhost:5678
  • Create a new workflow
  • Find your node in the node panel
  • Test parameters and functionality in real-time

šŸ“¦ Generated Project Commands

Your generated project comes with these convenient npm scripts:

Development

bash
npm run dev
# Runs: n8n-node dev

Building

bash
npm run build
# Runs: n8n-node build

Linting

bash
npm run lint
# Runs: n8n-node lint

npm run lint:fix
# Runs: n8n-node lint --fix

Publishing

bash
npm run release
# Runs: n8n-node release

šŸ“¦ Build & Deploy

Build for production

bash
npm run build

Generates:

  • Compiled TypeScript code
  • Bundled node package
  • Optimized assets and icons
  • Ready-to-publish package

Quality checks

bash
npm run lint

Validates:

  • Code style and formatting
  • n8n node conventions
  • Common integration issues
  • Cloud publication readiness

Cloud support

bash
npx n8n-node cloud-support

Manage n8n Cloud publication eligibility. In strict mode, your node must use the default ESLint config and pass all community node rules to be eligible for n8n Cloud publication.

Fix issues automatically:

bash
npm run lint:fix

Publish your node

bash
npm run release

Runs release-it to handle the complete release process:

  • Ensures working directory is clean
  • Verifies you're on the main git branch
  • Increments your package version
  • Runs build and lint checks
  • Updates changelog
  • Creates git tag with version bump
  • Creates GitHub release with changelog
  • Publishes to npm

šŸ“ Project Structure

Your generated project includes:

my-awesome-api-node/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ nodes/
│   │   └── MyAwesomeApi/
│   │       ā”œā”€ā”€ MyAwesomeApi.node.ts    # Main node logic
│   │       └── MyAwesomeApi.node.json  # Node metadata
│   └── credentials/
│       └── MyAwesomeApiAuth.credentials.ts
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
└── README.md

The CLI expects your project to follow this structure for proper building and development.

āš™ļø Configuration

The CLI reads configuration from your package.json:

json
{
  "name": "n8n-nodes-my-awesome-node",
  "n8n": {
    "n8nNodesApiVersion": 1,
    "nodes": [
      "dist/nodes/MyAwesomeApi/MyAwesomeApi.node.js"
    ],
    "credentials": [
      "dist/credentials/MyAwesomeApiAuth.credentials.js"
    ]
  }
}

šŸŽØ Node Types

Choose the right template for your use case:

TemplateBest ForFeatures
DeclarativeREST APIs, simple integrationsJSON-based configuration, automatic UI generation
ProgrammaticComplex logic, custom operationsFull TypeScript control, advanced error handling

šŸ› Troubleshooting

Common Issues

Node not appearing in n8n:

bash
# Clear n8n node cli cache and restart
rm -rf ~/.n8n-node-cli/.n8n/custom
npm run dev

TypeScript errors:

bash
# Reinstall dependencies
rm -rf node_modules npm-lock.yaml
npm install

Build failures:

bash
# Check for linting issues first
npm run lint --fix
npm run build

Development server issues:

bash
# Clear cache and restart development server
rm -rf ~/.n8n-node-cli/.n8n/custom
npm run dev

šŸ”§ Advanced Usage

Using External n8n Instance

If you prefer to use your own n8n installation:

bash
npm run dev --external-n8n

Custom User Folder

Specify a custom location for n8n user data:

bash
npm run dev --custom-user-folder /path/to/custom/folder

šŸ“š Resources

šŸ¤ Contributing

Found a bug or want to contribute? Check out the n8n repository and join our community!


Happy node building! šŸŽ‰