Starting from Fedora 24, npm is a part of Node.js package and does not need to be installed separately. Therefore, to install both npm and Node.js, you need to run:
$ sudo dnf install nodejs
There are alternative versions available as Fedora Modules.
Note: Modules are available for all editions from Fedora 29, and on the Server Edition from Fedora 28.
To list all available versions, run:
$ dnf module list
And to install an alternative version, run a command similar to this:
$ sudo dnf module install nodejs:8
Yarn package manager is available since Fedora 29. You can install it by running:
$ sudo dnf install nodejs-yarn
Because of conflicts with other packages, yarn has to be used in the following manner:
$ nodejs-yarn add request $ yarnpkg add request
If you still wish to use
yarn instead of
nodejs-yarn, the best way is to use bash alias.
Installing Node.js modules is covered in Node.js modules.