Error when trying to test node locally

Describe the issue/error/question

I am trying to switch the node I am working on to a community node.
I have followed these steps to test the node locally : Run your node locally - n8n Documentation

What is the error message (if any)?

When running n8n start, I get :

Error: Cannot find module '/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-nodes-opencell/dist/credentials/OpencellApi.credentials.ts'
Full error
❯ n8n start
Initializing n8n process
Error: Cannot find module '/opt/homebrew/lib/node_modules/n8n/node_modules/n8n-nodes-opencell/dist/credentials/OpencellApi.credentials.ts'
Require stack:
- /opt/homebrew/lib/node_modules/n8n/dist/src/LoadNodesAndCredentials.js
- /opt/homebrew/lib/node_modules/n8n/dist/src/index.js
- /opt/homebrew/lib/node_modules/n8n/dist/commands/start.js
- /opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/config/lib/plugin.js
- /opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/config/lib/config.js
- /opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/config/lib/index.js
- /opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js
- /opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/command/lib/index.js
- /opt/homebrew/lib/node_modules/n8n/bin/n8n
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at LoadNodesAndCredentialsClass.loadCredentialsFromFile (/opt/homebrew/lib/node_modules/n8n/src/LoadNodesAndCredentials.ts:193:22)
    at LoadNodesAndCredentialsClass.loadDataFromPackage (/opt/homebrew/lib/node_modules/n8n/src/LoadNodesAndCredentials.ts:580:10)
    at LoadNodesAndCredentialsClass.init (/opt/homebrew/lib/node_modules/n8n/src/LoadNodesAndCredentials.ts:80:4)
    at /opt/homebrew/lib/node_modules/n8n/commands/start.ts:195:5
    at Start.run (/opt/homebrew/lib/node_modules/n8n/commands/start.ts:157:3)
    at Start._run (/opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js:43:20)
    at Config.runCommand (/opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/config/lib/config.js:173:24)
    at Main.run (/opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/command/lib/main.js:27:9)
    at Main._run (/opt/homebrew/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js:43:20)

The /opt/homebrew/lib/node_modules/n8n/node_modules/n8n-nodes-opencell/dist/credentials/ directory contains the following files :

β”œβ”€β”€ credentials
β”‚   β”œβ”€β”€ OpencellApi.credentials.d.ts
β”‚   β”œβ”€β”€ OpencellApi.credentials.js
β”‚   β”œβ”€β”€ OpencellApi.credentials.js.map
β”‚   β”œβ”€β”€ OpencellOAuth2Api.credentials.d.ts
β”‚   β”œβ”€β”€ OpencellOAuth2Api.credentials.js
β”‚   └── OpencellOAuth2Api.credentials.js.map

(looks like transpiled typescript ?)

What did I get wrong ?

Thank you

Information on your n8n setup

  • n8n version: 0.188.0
  • Database you’re using (default: SQLite): sqlite3
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: npm

Hello @paulglx,

Did you make sure to run the second npm command in the main directory where you installed n8n? That could be the issue with this case.

Hi @rdt , thank you for your answer

I did run npm link <n8n-nodes-name> in the directory where I installed n8n.

With /opt/homebrew/lib/node_modules being the installation directory (given by npm root -g), I checked if the package has been linked correctly.


As this screenshot shows, the node_modules directory contains the symbolic link referring to the package, as I guess it should ?

In fact, the directory /opt/homebrew/lib/node_modules/n8n/node_modules/n8n-nodes-opencell/dist/credentials does exist and contains files whose names correspond to the files I developped for the node.

The files include :

  • …/dist/credentials/OpencellApi.credentials .d.ts
  • …/dist/credentials/OpencellApi.credentials .js
  • …/dist/credentials/OpencellApi.credentials .js.map

But when running n8n start, it looks like n8n is searching for (according to the error message) :

  • …/dist/credentials/OpencellApi.credentials .ts

Issue solved

The package.json was badly configured.
The file names should end with .js, not .ts !

The error

"n8n": {
    "credentials": [
      "dist/credentials/OpencellApi.credentials.ts",
      "dist/credentials/OpencellOAuth2Api.credentials.ts"
    ],
    (...)
  },

The solution

"n8n": {
    "credentials": [
      "dist/credentials/OpencellApi.credentials.js",
      "dist/credentials/OpencellOAuth2Api.credentials.js"
    ],
    (...)
  },
2 Likes

Awesome, happy to hear that the issue is resolved. Thank you for letting us know.