How to properly install package and optional dependency? (nodejs lts + npm)

Greetings community!

Probably dumb question, but I can’t figure this out on my own…

I want to install current nodejs lts + npm. Installing just nodejs-lts-hydrogen which has npm as optional dependency gives me only nodejs. On the other hand npm has as a dependency current nodejs, so if I’ll just separately install npm - it’ll also fetch current nodejs which I don’t need.

How can I tell pacman to install nodejs-lts-hydrogen together with npm as depandacy so that if say later I’ll decide to uninstall it with pacman -Rs - it’ll automatically remove npm as well?

And another question: npm is marked as outdated in the repo - is it at all safe to install such package?

I’m aware about nvm but I don’t like it and prefer not to use it since I need only one nodejs-npm pair anyway.

Here is one way:

sudo pacman -Syu nodejs-lts-hydrogen npm
sudo pacman -D --asdeps npm

Installing them both with one command solves the order problem and the second command marks npm as a dependency.

That basically means there is a newer version available then what is in the repos. I don’t have enough in-depth knowledge of npm to know if that is a problem or not.

In general, it is something to be aware of but not definitively a problem. It depends on the package and what is contained in the update(s).

Thank you so much!
Was reading a little bit about --asdeps option :slight_smile:

May I also ask one thing:

What do you mean by that? I’m afraid I don’t understand that statement. Is it about the fact that with such command npm during installation won’t pull current nodejs listed as ‘must’ dependency?

Yes. nodejs-lts-hydrogen provides nodejs. So if you have nodejs-lts-hydrogen installed(or are installing it) then npm will see it’s dependency as satisfied.

1 Like

That’s actually crucial information and really explains a lot. Thank you for the clarification!

1 Like

BTW…just for your knowledge you can see a lot of information about package with pacman -Si

For example, pacman -Si nodejs-lts-hydrogen shows this:

Repository      : community
Name            : nodejs-lts-hydrogen
Version         : 18.13.0-1
Description     : Evented I/O for V8 javascript (LTS release: Hydrogen)
Architecture    : x86_64
URL             : https://nodejs.org/
Licenses        : MIT
Groups          : None
Provides        : nodejs=18.13.0
Depends On      : openssl  zlib  icu  libuv  c-ares  brotli  libnghttp2
Optional Deps   : npm: nodejs package manager
Conflicts With  : nodejs
Replaces        : None
Download Size   : 9.93 MiB
Installed Size  : 41.72 MiB
Packager        : Bruno Pagani <archange@archlinux.org>
Build Date      : Sat 07 Jan 2023 08:25:36 AM CST
Validated By    : MD5 Sum  SHA-256 Sum  Signature
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.