Can't install

I try to install n8n on Ubuntu 20.04 with this command: npm install n8n -g but it gave error:

npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: [email protected]<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm WARN deprecated [email protected]: Please upgrade to latest, [email protected] or [email protected]! Check these notes: https://bit.ly/2ZEqIau
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
/usr/bin/n8n -> /usr/lib/node_modules/n8n/bin/n8n

> [email protected] install /usr/lib/node_modules/n8n/node_modules/cpu-features
> node buildcheck.js > buildcheck.gypi && node-gyp rebuild

sh: 1: cannot create buildcheck.gypi: Permission denied

> [email protected] install /usr/lib/node_modules/n8n/node_modules/ssh2
> node install.js

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/n8n/node_modules/ssh2/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/n8n/node_modules/ssh2/.node-gyp'
gyp ERR! System Linux 5.4.0-110-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "--target=v14.19.0" "--real_openssl_major=1" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/n8n/node_modules/ssh2/lib/protocol/crypto
gyp ERR! node -v v14.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
Failed to build optional crypto binding

> [email protected] install /usr/lib/node_modules/n8n/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v83 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding'
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.19.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/n8n/node_modules/sqlite3/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/n8n/node_modules/sqlite3/.node-gyp'
gyp ERR! System Linux 5.4.0-110-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"
gyp ERR! cwd /usr/lib/node_modules/n8n/node_modules/sqlite3
gyp ERR! node -v v14.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/n8n/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1058:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
node-pre-gyp ERR! System Linux 5.4.0-110-generic
node-pre-gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/n8n/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/lib/node_modules/n8n/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.19.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.9
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/lib/node_modules/n8n/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected]~2.3.2 (node_modules/n8n/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] requires a peer of @fortawesome/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @fortawesome/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @fortawesome/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/n8n/node_modules/cpu-features):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node buildcheck.js > buildcheck.gypi && node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 2

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-05-17T10_01_07_204Z-debug.log

the npm log is too big to post here so I’ll post near the bottom of the log.

25121 info lifecycle [email protected]~install: [email protected]
25122 silly install [email protected]
25123 info lifecycle [email protected]~install: [email protected]
25124 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false
25125 verbose lifecycle [email protected]~install: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/lib/node_modules/n8n/node_modules/sqlite3/node_modules/.bin:/usr/lib/node_modules/n8n/node_modules/.bin:/usr/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
25126 verbose lifecycle [email protected]~install: CWD: /usr/lib/node_modules/n8n/node_modules/sqlite3
25127 silly lifecycle [email protected]~install: Args: [ '-c', 'node-pre-gyp install --fallback-to-build' ]
25128 silly lifecycle [email protected]~install: Returned: code: 1  signal: null
25129 info lifecycle [email protected]~install: Failed to exec install script
25130 timing action:install Completed in 1615ms
25131 verbose unlock done using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
25132 timing stage:rollbackFailedOptional Completed in 2361ms
25133 timing stage:runTopLevelLifecycles Completed in 51315ms
25134 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected]~2.3.2 (node_modules/n8n/node_modules/chokidar/node_modules/fsevents):
25135 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
25136 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
25136 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
25136 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   linux
25136 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
25137 warn [email protected] requires a peer of @fortawesome/[email protected] but none is installed. You must install peer dependencies yourself.
25138 warn [email protected] requires a peer of @fortawesome/[email protected] but none is installed. You must install peer dependencies yourself.
25139 warn [email protected] requires a peer of @fortawesome/[email protected] but none is installed. You must install peer dependencies yourself.
25140 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/n8n/node_modules/cpu-features):
25141 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node buildcheck.js > buildcheck.gypi && node-gyp rebuild`
25141 warn optional SKIPPING OPTIONAL DEPENDENCY: Exit status 2
25142 verbose optional SKIPPING OPTIONAL DEPENDENCY:
25142 verbose optional Failed at the [email protected] install script.
25142 verbose optional SKIPPING OPTIONAL DEPENDENCY: This is probably not a problem with npm. There is likely additional logging output above.
25143 verbose stack Error: [email protected] install: `node-pre-gyp install --fallback-to-build`
25143 verbose stack Exit status 1
25143 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
25143 verbose stack     at EventEmitter.emit (events.js:400:28)
25143 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
25143 verbose stack     at ChildProcess.emit (events.js:400:28)
25143 verbose stack     at maybeClose (internal/child_process.js:1058:16)
25143 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
25144 verbose pkgid [email protected]
25145 verbose cwd /var/www/beta.adoreanime.com/htdocs
25146 verbose Linux 5.4.0-110-generic
25147 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "n8n" "-g"
25148 verbose node v14.19.0
25149 verbose npm  v6.14.16
25150 error code ELIFECYCLE
25151 error errno 1
25152 error [email protected] install: `node-pre-gyp install --fallback-to-build`
25152 error Exit status 1
25153 error Failed at the [email protected] install script.
25153 error This is probably not a problem with npm. There is likely additional logging output above.
25154 verbose exit [ 1, true ]

How to fix this?

Information on your n8n setup

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

Hey @Ruriko, welcome to the community :tada:

I am sorry to hear you’re having trouble with getting n8n up and running. The output you have shared suggests a permission problem to me:

(...)
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.19.0"
(...)
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/n8n/node_modules/ssh2/.node-gyp'
(...)

This is something I can’t reproduce on my end and I suspect it might be related to how you have installed Node.js and npm. You might want to try running the install command with sudo.

However, an easier way might be the use of docker. That way, all of the installation would happen in an isolated container coming with a working Node.js environment without having any effect on your existing setup. Assuming you have docker installed already, you could fire up an n8n container like this:

docker run -it --rm \
    --name n8n \
    -p 5678:5678 \
    -v ~/.n8n:/home/node/.n8n \
    n8nio/n8n