Problem updating n8n πŸ˜₯

Hello people! today I tried updating my self hosted N8N by usint the npm update -g n8n command,
and it took a long time to update so I killed it, and again tried doing it.
Before pressing ctrl+c, this was shown:

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]: this library is no longer supported
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]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
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]: 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]: 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]: 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]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
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.


Then I again gave the command and it showed 
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/n8n
npm ERR! dest /usr/local/lib/node_modules/.n8n-FThZbiYd
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/usr/local/lib/node_modules/n8n' -> '/usr/local/lib/node_modules/.n8n-FThZbiYd'
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-01-17T20_25_15_164Z-debug-0.log

I renamed the directory using mv command, as it needed.

then this was the error it showed when I again rerun the update command:

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'semver'
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/npm/lib/utils/unsupported.js',
    '/usr/share/npm/bin/npm-cli.js'
  ]
}

the output of the log file mentioned above is here: n8n err - Pastebin.com

Kindly help me out :sob::sob::sob: or if I have to reinstall, atleast help me recover my workflows​:sob::sob::sob:

Thank youπŸ˜₯

Probably best to totally uninstall n8n and reinstall it again.

You will not use your credentials or workflows as they are saved totally separate, in the .n8n folder underneath your users (if you use SQLite which I assume). Meaning if you start n8n after the reinstall again everything should be there again automatically.

1 Like

Could I reinstall N8N, and then copy the config and database.sqlite files from the old .n8n folder?

As mentioned above, is that not even necessary as n8n and the config are saved in totally different locations. So no matter where you install n8n will it read the data always from the same location (at least as long as the user does not change).

1 Like

I also want to upgrade the specs of my cloud VPS too, so I am hoping I can reinstall N8N on a new cloud instance, where its IP address and everything will change. In that case, is it feasible for me to copy the files from old cloud instance and paste it in the new instance?

Also, how to properly update N8N without running into problems like these?

Ah yes, if you move to a different instance then you can simply move that folder over.

Regarding easy upgrades. I would recommend using Docker over npm installing n8n. You can find the Server Setup guide here. That will make upgrading much easier and also reduces the chance of something going wrong a lot.

You can find information about how to upgrade if you use Docker here.

but installing using docker is too much of a hassle. I found npm to be easier.
Somewhere here I read we need to first stop npm n8n and then give the upgrade command, is it?

I reinstalled everything on an ever powerful machine with 6 GB of memory and 2 OCPUs. Also copied over the older folders to new instance and voila!!! IT WORKED!!!
Thanks a ton!!!

2 Likes