I’m working on building a custom node for n8n but running into an issue. After creating and building the node successfully, it’s not showing up in my local n8n instance. I can’t find it anywhere in the node list when I try to add it to a workflow. Has anyone faced this problem before? What might I be missing in the setup process?
import { INodeType, INodeTypeDescription } from 'n8n-workflow';
export class WeatherService implements INodeType {
description: INodeTypeDescription = {
displayName: 'Weather Service',
name: 'weatherService',
icon: 'file:weather.svg',
group: ['output'],
version: 1,
description: 'Fetch weather information',
defaults: {
name: 'Weather Service',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'weatherApiAuth',
required: true,
}
],
requestDefaults: {
baseURL: 'WEATHER_API_URL',
headers: {
'Content-Type': 'application/json'
}
},
properties: [
{
displayName: 'City Name',
name: 'cityName',
type: 'string',
placeholder: 'Enter city name',
required: true,
description: 'Name of the city to get weather for',
routing: {
request: {
method: 'POST',
url: 'WEATHER_ENDPOINT'
},
},
default: 'London',
}]
};
}
Here’s my weather.node.ts implementation.
{
"node": "n8n-nodes-weather.WeatherService",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Data & Storage"],
"resources": {
"credentialDocumentation": [],
"primaryDocumentation": []
}
}
This is my weather.node.json configuration.
import {
IAuthenticateGeneric,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class WeatherApiAuth implements ICredentialType {
name = 'WeatherApiAuth';
displayName = 'Weather API Token';
documentationUrl = 'https://example.com/weather-api-docs';
properties: INodeProperties[] = [
{
displayName: 'Access Token',
name: 'accessToken',
type: 'string',
default: '',
},
];
authenticate = {
type: 'generic',
properties: {
headers: {
'Authorization': 'Bearer ={{$credentials.accessToken}}'
}
},
} as IAuthenticateGeneric;
}
And this is my weather.credentials.ts file.