Install issue (test via npx and global install n8n) SyntaxError: Unexpected token '.' [SOLVED]

Describe the problem/error/question

I tried to install n8n but I get the same error message at each try.

What is the error message (if any)?

$ npx n8n
/home/admin/.npm/_npx/a8a7eec953f1f314/node_modules/n8n/bin/n8n:56
require('net').setDefaultAutoSelectFamily?.(false);
                                          ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
$ n8n
/usr/local/lib/node_modules/n8n/bin/n8n:56
require('net').setDefaultAutoSelectFamily?.(false);
                                          ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

Information on your n8n setup

  • n8n version: [email protected]
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ?
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy
$ npm --version
8.5.1

I’m listening to give more information it’s needed.

Thanks for your support,
David #firstTimeN8n

My NodeJs version is too old.

Optional chaining supported from Node. js version 14 .

Here’s how I solved my issue :

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

sudo apt-get update
sudo apt-get install -y nodejs

npm install n8n -g

Have fun,
David

2 Likes

Hi @davidbo

Thanks for posting here and welcome to the community!
Glad you worked it out and thanks for posting your update :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.