How To Update NPM Packages Without Sudo'ing

Continuing the discussion from [Failed update] error: failed to commit transaction (conflicting files):

I think the problem here is that unless the user does do sudo npm the packages do not get installed due to the location that npm is trying to install those packages i.e in /usr/lib/node_modules.

Is there a way to update the node modules without sudo’ing?

Yeah, never use sudo when installing node or python packages. You can change the default directory for global packages -

What problem?
The problem in the linked thread is someone messing up their system by using sudo.
It has no place in your npm/pip/etc package management.
For more information on how to handle npm properly, see this:

https://wiki.archlinux.org/title/Node.js#Managing_packages_with_npm

Thanks. I realise the problem I was making. I was using the -g option blindly which installed the packages globally instead of locally.