Command is not found when ran with sudo

760 Views Asked by At

I am trying to change the version of nodejs using cmd n installed globally by yarn. Neither yarn is detected by sudo nor n.

Please help me to fix this:

When running the n command to change node version, it shows permission is denied by many files to be written by n

enter image description here

1

There are 1 best solutions below

0
shadowspawn On

Two approaches to avoid permission issues without requiring use of sudo when running n:

  • install and run Node.js from your home folder using N_PREFIX and PATH (see also n-install which automates this)
  • if it is your personal computer, take ownership of the folders used with default install location of /usr/local

See the project README for more: https://github.com/tj/n

(Disclaimer: I am the maintainer of n.)