本地运行节点#
您可以通过在本地 n8n 实例中运行节点,边构建边测试。
- 使用 npm 安装 n8n:
npm install n8n -g
- 当您准备好测试节点时,请将其在本地发布:
# In your node directory npm run build npm link
- 将节点安装到本地 n8n 实例中:
# In the nodes directory within your n8n installation
# node-package-name is the name from the package.json
npm link <node-package-name>
检查目录
确保在您的 n8n 安装目录下的 nodes 文件夹中运行 npm link <node-name> 命令。该目录可能是:
~/.n8n/custom/~/.n8n/<your-custom-name>:如果您的 n8n 安装通过N8N_CUSTOM_EXTENSIONS设置了不同名称。
- 启动 n8n:
n8n start
-
在浏览器中打开 n8n。在节点面板中搜索时,您应该能看到您的节点。
节点名称
请确保使用节点名称而非包名称进行搜索。例如,若您的 npm 包名为
n8n-nodes-weather-nodes,且该包包含名为rain、sun、snow的节点,则应搜索rain而非weather-nodes。
故障排除#
若本地安装的 ~/.n8n 目录中不存在 custom 文件夹,您需要手动创建 custom 目录并运行 npm init:
# In ~/.n8n directory
run mkdir custom
cd custom
npm init