You are not logged in.

#1 2014-04-04 08:04:22

beardedlinuxgeek
Member
Registered: 2012-09-17
Posts: 32
Website

Best way to install nodejs packages? (npm vs pacman)

Most tutorials use npm to install nodejs modules. That makes sense to me, and it's kind of the whole point of npm and bower. But,  there are also copies of some these packages in the AUR.

I install nodejs-grunt-cli  some time ago with the standard

npm install -g grunt-cli

.

Today I tried to installed a program from the AUR which has nodejs-grunt-cli as a make depends. Obviously the automatic dependency resolution couldn't know that I already had grunt installed but in a different way. I edited the PKGBUILD and tried a few things to make it work but the build kept failing. I think something is just wrong with that package, but it's besides the point.

When you have the option to use npm or the AUR to install the same nodejs package, which do you use? And why?

Offline

#2 2014-04-04 10:00:05

Awebb
Member
Registered: 2010-05-06
Posts: 6,272

Re: Best way to install nodejs packages? (npm vs pacman)

If you want pacman to be aware of these things, you need to use pacman to install them. Other systems, like python, perl, ruby and others have such installers too and most of the packages are built with normal tarballs. I once suggested a combination, a PKGBUILD that uses the respective installer to fetch the package, but there were different reasons not to do this (package versions was one of them).

Offline

#3 2014-07-29 21:40:08

markwithk
Member
Registered: 2014-01-29
Posts: 5

Re: Best way to install nodejs packages? (npm vs pacman)

I always have this question. I really want to know how most people deal with this.

Offline

#4 2014-07-29 21:52:37

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,787
Website

Re: Best way to install nodejs packages? (npm vs pacman)

npm. It's rediculously time consuming and tedious maintaining hundreds of itty bitty nodejs packages, and offers no real benefit over just using npm directly.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2014-07-29 23:45:24

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,694
Website

Re: Best way to install nodejs packages? (npm vs pacman)

npm can install, uninstall and upgrade  just like packman does.

So, as far as I am concerned, using npm is just fine.
It is, however, the only case where I do not use packman. For everything else I use pacman.

I've been using npm for some time now and never had a problem. smile

R.

Offline

#6 2014-07-30 00:07:32

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: Best way to install nodejs packages? (npm vs pacman)

I've yet to do anything serious with npm, but it's my understanding that you can write an ~/.npmrc file to set the path of the Node runtime (like you can with Rubygems and Pip). So you can set "npm install -g" to install the Node packages to some directory in $HOME, add that directory to your $PATH and keep the packages sequestered from the rest of the system. It's how I manage Ruby gems, since it's often necessary to have multiple versions installed. The couple times things have gotten unmanageable, I just wiped the ~/.gem directory and reinstalled what I needed.

Offline

#7 2014-08-12 00:36:44

rbellamy
Member
Registered: 2012-11-30
Posts: 17

Re: Best way to install nodejs packages? (npm vs pacman)

I'm conflicted by the general case of this question more than the specifics.

I'm not satisfied with either of these solutions:

  1. Use pacman - this leaves you having to manage the hundreds or thousands of associated packages yourself, or trust that some other user has created a viable set of PKGBUILDs.

  2. Use the ecosystem that comes with the runtime - this leaves you with numerous files and directories that are no longer under pacman management, and trusts that these runtime-managed packages can deal well with outside dependencies.

A material example I ran into not long ago:

  • Installed npm

  • Wanted to downsample high-pixel-density images during Grunt build

  • Used npm to install node-spritesheet, which requires ImageMagick

  • Used pacman to install ImageMagick - THIS WAS DONE MANUALLY, npm doesn't talk to the OS package manager

Offline

#8 2014-08-30 07:21:53

bobbaluba
Member
Registered: 2013-08-06
Posts: 12

Re: Best way to install nodejs packages? (npm vs pacman)

What do you think about the npm2arch script in the AUR?

Offline

#9 2015-08-27 09:45:22

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Best way to install nodejs packages? (npm vs pacman)

I recommend that you have a local installation of nodejs and use npm to install packages there. Just like you prefer using rbenv for ruby and virtualenv for python.

The way I like to do it is:

1. Unpack the official pre-built binaries into ~/.node (.e.g https://nodejs.org/dist/v0.12.7/node-v0 … x64.tar.gz would be unpacked in ~/.node/node-v0.12.7-linux-x64
2. Add a symlink called current to your wanted node version (e.g. ln -s ~/.node/node-v0.12.7-linux-x64 ~/.node/current)
3. Add ~/.node/current/bin to your path (e.g echo export PATH=$HOME/.node/current/bin:$PATH >> ~/.bashrc)


This way you can just type npm install whatever and it's installed into your local npm version that you have symlinked under ~/.node/current. If you want to change the version you're using, just point the symlink somewhere else.

I believe this mimics rbenv quite well and is beautiful in it's simplicity.


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#10 2015-08-28 08:44:52

Awebb
Member
Registered: 2010-05-06
Posts: 6,272

Re: Best way to install nodejs packages? (npm vs pacman)

I don't prefer virtualenv, I install all python packages with pacman, write PKGBUILDs if I have to. I trust pip less than I trust the Arch maintainers and AUR volunteers.

Software, that runs with enough permissions to change itself, is scary enough in on itself, but software that is changeable in the same space as a web browser can write to, is irresponsible.

Use local installs during development, if you trust your setup, but any deployment should be a legal operation between you, your software and the resident package manager.

Offline

#11 2015-09-04 14:05:37

boban_dj
Member
Registered: 2015-03-17
Posts: 150

Re: Best way to install nodejs packages? (npm vs pacman)

I did it like this:
Installation: node.js fix for arch (use python2)

mkdir /tmp/bin
ln -s /usr/bin/python2 /tmp/bin/python
export PATH=/tmp/bin:$PATH

The temporary PATH will be normal when you close the current cli.
You can then do a regular node install, for whatever version you need:

git clone git://github.com/joyent/node.git
git checkout v0.12.7

./configure && make && make install

Node will be installed in `/usr/local/bin/node`,
Npm will be installed in `/usr/local/bin/npm`,
and your Node modules will be installed in `/usr/local/lib/node_modules`.

Now you can change the prefix for npm:

$ npm config get prefix
/usr/local
$ mkdir ~/.node_modules_global
$ npm config set prefix=$HOME/.node_modules_global
$ npm install npm --global

in ~/.bash_profile

export PATH="$HOME/.node_modules_global/bin:$PATH"
$ which npm
/home/boban/.node_modules_global/bin/npm

Last edited by boban_dj (2015-09-16 09:21:44)

Offline

#12 2015-09-13 10:02:50

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Best way to install nodejs packages? (npm vs pacman)

boban_dj wrote:

I did it like this:
Installation: node.js fix for arch (use python2)

mkdir /tmp/bin
ln -s /usr/bin/python2 /tmp/bin/python
export PATH=/tmp/bin:$PATH

nodejs docs wrote:

If your Python binary is in a non-standard location or has a non-standard name, run the following instead:

$ export PYTHON=/path/to/python
$ $PYTHON ./configure
$ make
$ [sudo] make install
boban_dj wrote:

The temporary PATH will be normal when you close the current cli.
You can then do a regular node install, for whatever version you need:

git clone git://github.com/joyent/node.git
git checkout v0.12.7

./configure && make && sudo make install

Node will be installed in `/usr/local/bin/node`,
Npm will be installed in `/usr/local/bin/npm`,
and your Node modules will be installed in `/usr/local/lib/node_modules`.

Never run make install as root, there is absolutely 0 reasons do to so

Also your url is outdated, node moved to github/nodejs

boban_dj wrote:

Now you can change the prefix for npm:

$ npm config get prefix
/usr/local
$ mkdir ~/.node_modules_global
$ npm config set prefix=$HOME/.node_modules_global
$ npm install npm --global

in ~/.bash_profile

export PATH="$HOME/.node_modules_global/bin:$PATH"
$ which npm
/home/boban/.node_modules_global/bin/npm

Or just install npm from the repo in the first place and use it to install node crud to $HOME, thereby avoiding all the things I pointed out in the first place.

Last edited by Mr.Elendig (2015-09-13 10:09:14)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#13 2019-05-16 23:39:12

4internetanonymity
Member
Registered: 2009-07-09
Posts: 56

Re: Best way to install nodejs packages? (npm vs pacman)

Old thread, I realize, but those are some of the best. Any advice or ideas for long-term nodejs server maintenance on Arch? I have a nodejs server that I want to keep running for 10+ years, and I'm considering launching it on Arch. It is mostly nodejs, react, and some databases.

Offline

#14 2019-05-17 01:38:43

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: Best way to install nodejs packages? (npm vs pacman)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB