Custom Node Creation Error

Errors when I try to build a declarative-style node

What is the error message (if any)?

I was follow this documentation guide but I got some error in the step when I try to publish the custom node I run:

npm run build

but I got this error:

ReferenceError: priomordials is not defined

Also when I try to start n8n

n8n start

I got this error about node_modules/@azure

import * as fs from "fs";
^^^^^

SyntaxError: Cannot use import statement outside a module

Information on your n8n setup

  • node version: 18.19.0
  • n8n version: 1.29.1
  • Running n8n via: npm
  • Operating system: ubuntu 20.04

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • node version: 18.19.0
  • n8n version: 1.29.1
  • Running n8n via: npm
  • Operating system: ubuntu 20.04

Hey @jomitame,

Is priomordials something you are trying to use?

Hi @Jon

I really appreciate you help me.

I’m sorry, but I don’t understand what you mean by “priomordials”.

I only want to create a custom node following the documentation, but I couldn’t do it because different errors appear.

I’m a little sad about that, because it seems simple as the documentation shows it but it’s different in reality.

Hey @jomitame,

In your error it mentions priomordials I was wondering if that was something you were using in your node or if that is coming from somewhere else.

Are you able to share the code for your node? Are you also trying to do the development on Windows, I have seen a lot of issues recently with some of the npm packages causing issues on Windows.

Having the same problem. I have followed the guide to create a custom module. I’m now trying to start testing it by including it in a local n8n instance.
I have created the ~/.n8n/custom folder. Run npm init and used all the default options. Run npm link <my node package> which has copied it into a node_modules folder in there.
But when I run n8n start I get

User settings loaded from: C:\Users<username>.n8n\config
Initializing n8n process
Error loading node “utils” from: “C:/Users//.n8n/custom/node_modules//node_modules/@azure/storage-blob/dist-esm/storage-blob/src/utils/utils.node.js” - Cannot use import statement outside a module
C:\Users<username>\source\Nodes\node_modules@azure\storage-blob\dist-esm\storage-blob\src\utils\utils.node.js:3
import * as fs from “fs”;
^^^^^^

SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Object.Module._extensions…js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at evalmachine.:1:6
at Script.runInContext (node:vm:133:12)
at loadClassInIsolation (C:\Users<username>\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\ClassLoader.ts:9:16)
at CustomDirectoryLoader.loadNodeFromFile (C:\Users<username>\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\DirectoryLoader.ts:83:35)
at CustomDirectoryLoader.loadAll (C:\Users<username>\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\DirectoryLoader.ts:312:9)
at LoadNodesAndCredentials.runDirectoryLoader (C:\Users<username>\AppData\Roaming\npm\node_modules\n8n\src\LoadNodesAndCredentials.ts:257:3)
at LoadNodesAndCredentials.loadNodesFromCustomDirectories (C:\Users<username>\AppData\Roaming\npm\node_modules\n8n\src\LoadNodesAndCredentials.ts:175:4)
at LoadNodesAndCredentials.init (C:\Users_\AppData\Roaming\npm\node_modules\n8n\src\LoadNodesAndCredentials.ts:94:3)
Error: Exiting due to an error.
SyntaxError: Cannot use import statement outside a module

Hey @ciaranodonnell,

I have seen this a bunch now and it seems to mainly impact WIndows users, Can you share the package.json for your node?

@marcus when you get a chance can you run through the node building guide on your maching to see if you hit the same issue?

{
“name”: “n8n-nodes-AgentLoader”,
“version”: “0.1.1”,
“description”: “n8n node to load the Genie Agent from the Agent API and make it available to other nodes”,
“keywords”: [
“genie-agent”,
“n8n-community-node-package”
],
“license”: “MIT”,
“homepage”: “”,
“author”: {
“name”: “Ciaran O’Donnell”,
“email”: “[email protected]
},
“repository”: {
“type”: “git”,
“url”: “”
},
“main”: “index.js”,
“scripts”: {
“build”: “tsc && gulp build:icons”,
“dev”: “tsc --watch”,
“format”: “prettier nodes credentials --write”,
“lint”: “eslint nodes credentials package.json”,
“lintfix”: “eslint nodes credentials package.json --fix”,
“prepublishOnly”: “npm run build && npm run lint -c .eslintrc.prepublish.js nodes credentials package.json”
},
“files”: [
“dist”
],
“n8n”: {
“n8nNodesApiVersion”: 1,
“credentials”: [
“dist/credentials/AgentLoader.credentials.js”
],
“nodes”: [
“dist/nodes/AgentLoader/AgentLoader.node.js”
]
},
“devDependencies”: {
@types/express”: “^4.17.6”,
@types/request-promise-native”: “~1.0.15”,
@typescript-eslint/parser”: “~5.45”,
“eslint-plugin-n8n-nodes-base”: “^1.11.0”,
“gulp”: “^4.0.2”,
“n8n-core”: “",
“n8n-workflow”: "
”,
“prettier”: “^2.7.1”,
“typescript”: “~4.8.4”
}
}

I’ve tried the Build a declarative-style node tutorial on my windows machine and it worked.

By the way @ciaranodonnell, in your package.json devDependencies you have

"n8n-core": "",
"n8n-workflow": "",

where it should be

"n8n-core": "*",
"n8n-workflow": "*",

But the rest is basically the same as mine.

It does have the * - i guess that was lost on the copy and paste operation.

I am trying to build the code based one.
The problem for me is n8n-core depends on snowflake which depends on @azure/storage-blob and @azure/storage-blob uses imports but n8n loads it through a require.
Other people in my organization have tried this and got the same results. This is a total blocker to our adoption at the moment

Hello,

I got also the error:

Error loading node "utils" from: "/Users//.n8n/custom/node_modules/n8n-custom-nodes/node_modules/@azure/storage-blob/dist-esm/storage-blob/src/utils/utils.node.js" - Cannot use import statement outside a module
/Users//Documents/GIT/n8n-custom-nodes/node_modules/@azure/storage-blob/dist-esm/storage-blob/src/utils/utils.node.js:3
  • node version: v18.19.1
  • n8n version: 1.32.2
  • Running n8n via: npm
  • Operating system: macOS 14.1.2 (23B92)

Here my package.json

{
  "name": "n8n-custom-nodes",
  "version": "0.1.0",
  "description": "",
  "keywords": [
    "n8n-community-node-package"
  ],
  "license": "MIT",
  "homepage": "",
  "author": {
    "name": "",
    "email": ""
  },
  "repository": {
    "type": "git",
    "url": "https://github.com//n8n-custom-nodes.git"
  },
  "main": "index.js",
  "scripts": {
    "build": "tsc && gulp build:icons",
    "dev": "tsc --watch",
    "format": "prettier nodes credentials --write",
    "lint": "eslint nodes credentials package.json",
    "lintfix": "eslint nodes credentials package.json --fix",
    "prepublishOnly": "npm run build && npm run lint -c .eslintrc.prepublish.js nodes credentials package.json"
  },
  "files": [
    "dist"
  ],
  "n8n": {
    "n8nNodesApiVersion": 1,
    "credentials": [
      "dist/credentials/ExampleCredentialsApi.credentials.js",
      "dist/credentials/HttpBinApi.credentials.js"
    ],
    "nodes": [
      "dist/nodes/ExampleNode/ExampleNode.node.js",
      "dist/nodes/HttpBin/HttpBin.node.js"
    ]
  },
  "devDependencies": {
    "@types/express": "^4.17.6",
    "@types/request-promise-native": "~1.0.15",
    "@typescript-eslint/parser": "~5.45",
    "eslint-plugin-n8n-nodes-base": "^1.11.0",
    "gulp": "^4.0.2",
    "n8n-core": "*",
    "n8n-workflow": "*",
    "prettier": "^2.7.1",
    "typescript": "~4.8.4"
  }
}

Does anyone have any idea how to fix this problem? I really wish I could work at n8n.

Hello,
I tested it with a Linux and I have the problem too :confused:

Can you share a link to a GitHub repo with your code in it? I have just given our example repo a test and it seems to build without issue on my Mac.

Hello @Jon,

Here My GitHub repository. I have only cloned the project and changed the project name in the package.json file. I encounter the problem only when I link this project to my global n8n (/Users/<username>/.n8n/custom ).

Thanks for your help.

Hey @Xavier-Cliquennois,

Can you share the commands and folders you are using for the linking?

Hello @Jon,

I assume it works for you? :sweat_smile:
Here are all the commands I made:

npm i n8n -g
n8n start // only to generate the .n8n folder
git clone [email protected]:Xavier-Cliquennois/n8n-custom-nodes.git
cd /Users/xaviercliquennois/Documents/GIT/n8n-custom-nodes
npm i 
npm link
cd /Users/xaviercliquennois/.n8n
mkdir custom
cd custom
npm init // I use default setting for all package.json config
npm link n8n-custom-nodes
n8n start // crash here

Here the content of .n8n/custom

Global link

I guess I’m the problem in this story.

Thank you in advance for the help.

Hey @Xavier-Cliquennois,

That did it, I had to jump on a new machine as well. Oddly while that failed a node I made 7 months ago can be linked without issue so I wonder if there is an issue with the example nodes.

For now I would suggest starting on your node and clearing out the examples then following the get started guide we have or if you wanted a starting point I have just tested this: GitHub - Joffcom/n8n-nodes-digital-ocean in the same way and it does work.

It works :partying_face:. Thanks for your help @Jon.

Maybe it would be necessary to remove the 2 example nodes from the GitHub repository and update the tutorial page? It would be a shame if people didn’t participate in this great project because of this issue.