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 request-promise-native@1.0.9: 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 request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: 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 core-js@2.6.12: core-js@<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 formidable@1.2.6: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau
npm WARN deprecated uuid@3.3.2: 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 querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
/usr/bin/n8n -> /usr/lib/node_modules/n8n/bin/n8n

> cpu-features@0.0.4 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

> ssh2@1.10.0 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

> sqlite3@5.0.8 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 sqlite3@5.0.8 and node@14.19.0 (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: fsevents@~2.3.2 (node_modules/n8n/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN n8n-design-system@0.20.0 requires a peer of @fortawesome/fontawesome-svg-core@1.x but none is installed. You must install peer dependencies yourself.
npm WARN n8n-design-system@0.20.0 requires a peer of @fortawesome/free-solid-svg-icons@5.x but none is installed. You must install peer dependencies yourself.
npm WARN n8n-design-system@0.20.0 requires a peer of @fortawesome/vue-fontawesome@2.x but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: cpu-features@0.0.4 (node_modules/n8n/node_modules/cpu-features):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: cpu-features@0.0.4 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! sqlite3@5.0.8 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@5.0.8 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 prom-client@13.2.0~install: prom-client@13.2.0
25122 silly install sqlite3@5.0.8
25123 info lifecycle sqlite3@5.0.8~install: sqlite3@5.0.8
25124 verbose lifecycle sqlite3@5.0.8~install: unsafe-perm in lifecycle false
25125 verbose lifecycle sqlite3@5.0.8~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 sqlite3@5.0.8~install: CWD: /usr/lib/node_modules/n8n/node_modules/sqlite3
25127 silly lifecycle sqlite3@5.0.8~install: Args: [ '-c', 'node-pre-gyp install --fallback-to-build' ]
25128 silly lifecycle sqlite3@5.0.8~install: Returned: code: 1  signal: null
25129 info lifecycle sqlite3@5.0.8~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: fsevents@~2.3.2 (node_modules/n8n/node_modules/chokidar/node_modules/fsevents):
25135 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: 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 n8n-design-system@0.20.0 requires a peer of @fortawesome/fontawesome-svg-core@1.x but none is installed. You must install peer dependencies yourself.
25138 warn n8n-design-system@0.20.0 requires a peer of @fortawesome/free-solid-svg-icons@5.x but none is installed. You must install peer dependencies yourself.
25139 warn n8n-design-system@0.20.0 requires a peer of @fortawesome/vue-fontawesome@2.x but none is installed. You must install peer dependencies yourself.
25140 warn optional SKIPPING OPTIONAL DEPENDENCY: cpu-features@0.0.4 (node_modules/n8n/node_modules/cpu-features):
25141 warn optional SKIPPING OPTIONAL DEPENDENCY: cpu-features@0.0.4 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 cpu-features@0.0.4 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: sqlite3@5.0.8 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 sqlite3@5.0.8
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 sqlite3@5.0.8 install: `node-pre-gyp install --fallback-to-build`
25152 error Exit status 1
25153 error Failed at the sqlite3@5.0.8 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