Is there way to install npm or yarn pakage without sudo

I am a new user for endeavouros.I mostly do React js / Node js / Nest js work using endeavouros.
I installed node using these commands:- sudo pacman -S nodejs / sudo pacman -S npm.
Now I can’t install anything related above programming stuff. Alway need to use sudo , Is their way to by pass sudo install…?

There is no way to install via pacman without sudo elevation, why are you trying to pass sudo if i may ask.

1 Like

No no. I mean if I need to install nodemon i can’t download the default command.(npm install nodemon)
I have to use (sudo npm install nodemon).I need to skip this sudo install npm pkage

I see, try creating a folder in say, your home directory and point npm towards it to see if you can use it afterwards.
like so:

  • mkdir ~/.my_npm_packages
  • npm config set prefix ~/.my_npm_packages
2 Likes

Thanks…:heart::ok_hand:

glad i helped, if it was indeed the solution could you please mark it as such so everybody else who might see this knows.

3 Likes

Why not? By default, npm will install to the current directory:

$ cd $(mktemp -d)
$ node install nodemon
added 116 packages, and audited 117 packages in 19s

15 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New patch version of npm available! 8.1.3 -> 8.1.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.4
npm notice Run npm install -g npm@8.1.4 to update!
npm notice 

$ ls -l
total 80
drwxr-xr-x 110 jonathon jonathon  2220 Nov 23 21:16 node_modules
-rw-r--r--   1 jonathon jonathon    53 Nov 23 21:16 package.json
-rw-r--r--   1 jonathon jonathon 77688 Nov 23 21:16 package-lock.json

$ npm list
npm list
tmp.mz88fKo6Li@ /tmp/tmp.mz88fKo6Li
└── nodemon@2.0.15

I had to add this to my .zshrc

export PATH=~/.npm-global/bin:$PATH

http://npm.github.io/installation-setup-docs/installing/a-note-on-permissions.html

Thanks…:heart::ok_hand:

Sorry but it’s not working.

I pick this link from the reply and this works fine. http://npm.github.io/installation-setup-docs/installing/a-note-on-permissions.html