
Fedora 45 gives you several solid ways to run Node.js and npm, and the right choice depends less on “which command works” than on how the machine will be used. A developer workstation that needs to switch between project versions benefits from a Node version manager. A production server that should receive predictable security updates usually belongs under DNF. A CI runner or container image may need a pinned upstream version instead.
Fedora’s official repositories include Node.js and npm, so the fastest route is often a single DNF command. The important detail is that Fedora 45 changed how its Node packages are organized. The plain nodejs package provides a recommended interpreter version, while packages such as nodejs24 and nodejs26 install a specific major version that Fedora will not silently change across system upgrades.
This guide covers all three practical approaches: DNF-managed packages, NodeSource for upstream releases, and fnm for per-user version switching. It also covers the mistakes that tend to show up after installation: conflicting repositories, global npm permission errors, native module build failures, and Node processes that disappear after a reboot.
Before You Begin
Start with a current system. On Fedora, package metadata and repository definitions can change between releases, and an outdated DNF cache can make an otherwise straightforward installation confusing.
sudo dnf upgrade --refresh -y
sudo dnf check-update
Check the architecture and confirm that you have enough free disk space. Node.js itself is small, but dependency caches, global tools, Docker images, and build artifacts can consume far more space than people expect.
uname -m
df -h /
For a typical development workstation, 2 GB RAM is enough to install and run Node.js. For a production Node application, plan capacity around the workload rather than the runtime. A small API service may run comfortably in 512 MB to 1 GB, while a Next.js build, bundler, test suite, or high-concurrency API can temporarily consume several gigabytes.
Decide on an installation method
| Method | Best for | Update behavior | Version control |
|---|---|---|---|
| Fedora DNF | Servers, simple workstations, distro-managed environments | Updated through dnf upgrade |
Limited to Fedora-packaged versions |
| NodeSource RPM | A specific upstream Node major release | Updated through DNF from NodeSource repository | Major version selected by repository |
fnm |
Developers, multi-project machines, local testing | Managed explicitly by the user | Full control per shell or project |
| Official binaries | Containers, isolated environments, custom deployments | Manual | Exact version and installation path |
There is no universally “best” method. The wrong choice is mixing several methods on the same system without understanding which one owns /usr/bin/node.
Method 1: Install Node.js and npm with DNF
For most Fedora 45 users, DNF is the cleanest starting point. It integrates with the system package manager, receives updates through the normal Fedora update process, and avoids adding an external repository unless you actually need one.
Fedora’s developer documentation states that npm is included with the Node.js package, so installing nodejs brings in the runtime, V8 JavaScript engine, and npm. The Fedora quick documentation also shows nodejs npm as the package installation command, which is useful when you want to make the npm dependency explicit.
Install the recommended Node.js version
sudo dnf install -y nodejs npm
Verify the installation:
node --version
npm --version
rpm -q nodejs
You should see output similar to this, though the exact patch version will differ:
v22.x.x
11.x.x
nodejs-22.x.x-...fc45.x86_64
The nodejs package is intended to provide a stable, recommended version of the interpreter and associated tools. Fedora may upgrade it to a newer major version during a system upgrade, so it is not the best fit if your application must remain locked to a particular Node major release.
Install a specific Node.js major version
If your project requires Node.js 24 or Node.js 26, install the versioned package instead:
sudo dnf install -y nodejs24
Or, for Node.js 26:
sudo dnf install -y nodejs26
These versioned packages are designed to remain on the selected major version even across Fedora system upgrades. That makes them useful when an application has a documented Node compatibility requirement. The tradeoff is that Fedora may eventually stop supporting that specific version, leaving long-term maintenance to the administrator.
Verify the versioned installation:
node --version
npm --version
rpm -qa | grep '^nodejs'
On a clean system, this should show the matching Node and npm packages. Fedora’s versioned packages include npm components under names such as nodejs24-npm or nodejs26-npm, depending on the branch installed.
When DNF is the right choice
Use DNF when any of the following applies:
- You are setting up a single-purpose production server.
- You want Node.js updates handled through normal Fedora maintenance.
- You do not need to switch Node versions between projects.
- You prefer RPM-managed files under
/usrrather than files in a user’s home directory. - You are building a minimal server image or automated provisioning workflow.
For a production deployment, DNF also makes rollback and auditing easier. You can inspect installed package versions, query repository ownership, and use standard Fedora tooling rather than maintaining a separate Node lifecycle outside the operating system.
Method 2: Install Node.js from NodeSource
NodeSource provides upstream Node.js RPM packages for Fedora and Enterprise Linux systems. It is a good option when Fedora’s packaged version does not match the release your application needs, or when you want to follow a particular upstream LTS or Current line.
The npm documentation recommends NodeSource when a Node version manager is not being used. That recommendation makes sense for servers. NodeSource packages install into standard system paths and can be updated with DNF, while still giving you more control over the Node major version than the default Fedora package.
Add the NodeSource repository
First, decide which major version you need. For example, to install Node.js 24:
curl -fsSL https://rpm.nodesource.com/setup_24.x -o /tmp/nodesource_setup.sh
less /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
Then install Node.js and npm:
sudo dnf install -y nodejs
Verify it:
node --version
npm --version
rpm -q nodejs
dnf repolist | grep -i nodesource
The setup script writes a repository definition and imports the signing key. Reviewing it before execution is not paranoia. It is basic server hygiene. A package repository can install software with root privileges, so it deserves the same scrutiny as any other third-party source.
Choose the correct NodeSource branch
Replace 24.x with the major version you need:
curl -fsSL https://rpm.nodesource.com/setup_22.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
sudo dnf install -y nodejs
For Node.js 26:
curl -fsSL https://rpm.nodesource.com/setup_26.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
sudo dnf install -y nodejs
Do not run multiple NodeSource setup scripts blindly on the same server. Each script can replace or modify repository configuration, and having several Node sources enabled creates exactly the kind of dependency conflict that is annoying to diagnose at 2 a.m.
Remove Fedora Node packages first if necessary
If Fedora’s Node.js package is already installed and you intend for NodeSource to own Node, remove the Fedora packages first. Otherwise, DNF may keep the existing installation or report conflicts.
sudo dnf remove -y nodejs npm 'nodejs2*'
sudo dnf clean all
Then add the NodeSource repository and install Node.js again.
This is one of those steps that experienced administrators do not skip. Package conflicts between distribution and third-party repositories rarely announce themselves clearly. They often appear later as an unexpected Node version, a missing npm binary, or a dependency resolution error during an unrelated update.
Method 3: Install Node.js with fnm
fnm, short for Fast Node Manager, is a practical choice for developer workstations. It installs Node.js versions in your user directory, avoids requiring root for routine version changes, and lets different terminal sessions use different Node versions.
This approach is especially useful when you maintain several applications. One legacy service may require Node 18, a current project may use Node 22, and another may need Node 24. Installing all of those through system packages would be awkward.
Install fnm
Fedora may offer fnm through DNF. Check first:
dnf search fnm
If it is available:
sudo dnf install -y fnm
If it is not available in your enabled repositories, install the upstream binary into a user-controlled directory:
mkdir -p ~/.local/bin
curl -fsSL https://fnm.vercel.app/install | bash
Then ensure ~/.local/bin is in your PATH. Add this to ~/.bashrc if necessary:
export PATH="$HOME/.local/bin:$PATH"
Reload the shell configuration:
source ~/.bashrc
Enable fnm in your shell
For Bash:
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.bashrc
source ~/.bashrc
For Zsh:
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrc
The --use-on-cd option makes fnm switch to the Node version declared by a project when you enter its directory, provided the project includes a .node-version or .nvmrc file.
Install Node.js versions
Install the current LTS release:
fnm install --lts
Install a specific version:
fnm install 22
fnm install 24
Set a default version:
fnm default 22
Verify:
fnm current
node --version
npm --version
Use a project-specific Node version
Inside a project directory, create either .nvmrc or .node-version:
echo "22" > .nvmrc
Then enter the directory:
cd ~/projects/my-app
fnm use
If fnm is configured with --use-on-cd, it should switch automatically. This prevents the familiar situation where one developer runs tests successfully while another sees cryptic engine errors because their shell is using a different Node release.
When fnm is the right choice
Use fnm when:
- You work on multiple Node.js projects with different runtime requirements.
- You need to test an application against several Node versions.
- You want Node installed without root privileges.
- You are setting up a developer workstation rather than a shared production server.
- You want project-level version pinning through
.nvmrcor.node-version.
Avoid using fnm as the only Node installation on a production server unless you have a strong reason. Version managers are excellent for developers, but production systems benefit from explicit package ownership, predictable upgrade paths, and configuration managed through infrastructure tooling.
Verify the Installation
A successful install is more than a Node version number. Confirm that both binaries resolve to the expected locations and that npm can actually install packages.
which node
which npm
node --version
npm --version
Expected output looks like this:
/usr/bin/node
/usr/bin/npm
v22.x.x
11.x.x
If you used fnm, the paths may point into ~/.local/share/fnm or a similar user directory. That is normal.
Run a quick smoke test:
node -e "console.log('Node.js is working:', process.version)"
Then create a temporary project and install a small package:
mkdir -p ~/nodejs-test && cd ~/nodejs-test
npm init -y
npm install left-pad
node -e "console.log(require('left-pad')('fedora', 10))"
If npm can create package-lock.json, download a package, and Node can require it, the basic toolchain is working.
Configure npm Properly
npm stores configuration in several places. The two most important are the user-level configuration file and the project-level .npmrc file.
Check the active configuration:
npm config list
npm config get registry
npm config get cache
Set a custom npm cache location
On servers with limited disk space or ephemeral root filesystems, moving the npm cache can prevent unnecessary writes to the system partition.
mkdir -p ~/.npm-cache
npm config set cache ~/.npm-cache
For a service account, place the cache somewhere with adequate space and appropriate ownership:
sudo mkdir -p /var/cache/nodejs
sudo chown -R nodeapp:nodeapp /var/cache/nodejs
sudo -u nodeapp npm config set cache /var/cache/nodejs/npm-cache
Use a private registry
Corporate environments often use a private npm registry, such as Verdaccio, Artifactory, GitHub Packages, or a cloud-hosted proxy. Configure it per project rather than globally when possible:
cd ~/projects/my-app
npm config set registry https://registry.example.com/
For scoped packages, use an .npmrc file in the repository:
@mycompany:registry=https://npm.pkg.example.com/
//npm.pkg.example.com/:always-auth=true
Never commit an authentication token to a public repository. Use environment variables, a secrets manager, or a CI/CD secret store instead.
Disable optional telemetry where appropriate
Some organizations restrict outbound telemetry. npm configuration and environment variables can control certain behaviors, but the exact settings depend on the npm version and corporate policy. Review npm config list and your organization’s security baseline before enabling or disabling anything.
Global npm Packages: The Right Way
Global npm packages are convenient, but they are also a frequent source of permission problems. A globally installed CLI tool becomes available across the system, which is useful for tools such as pnpm, yarn, typescript, or eslint.
npm install -g pnpm
If you installed Node.js through DNF or NodeSource, global packages are normally installed under a root-owned system path. Running npm install -g as a regular user can therefore fail with EACCES.
Avoid sudo for npm global installs
Do not make a habit of running this:
sudo npm install -g some-package
It can work, but it encourages a security pattern where npm packages execute with elevated privileges. A malicious or compromised package could potentially modify system files. Treat global installs like any other system-level software change: understand what is being installed and why.
Better options for global CLI tools
For project-local tools, install them as development dependencies:
npm install --save-dev eslint
npx eslint .
For personal CLI tools, use a user-level npm prefix:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
npm install -g pnpm
This keeps globally installed npm tools under your home directory and avoids permission conflicts with system packages.
Troubleshooting Common Problems
command not found: node
This usually means one of three things:
- Node.js was not installed.
- The binary is installed but not in
PATH. - A shell configuration change has not been loaded.
Check the binary directly:
command -v node
ls -l /usr/bin/node
rpm -q nodejs
If Node is installed but not found, inspect your PATH:
echo "$PATH"
For fnm, ensure the initialization line is present in the correct shell startup file. Bash reads ~/.bashrc for interactive non-login shells on Fedora, while Zsh commonly uses ~/.zshrc.
EACCES: permission denied during npm install
This is the classic global npm permission issue. It often appears when npm tries to write to /usr/lib/node_modules or /usr/bin.
Check the npm prefix:
npm config get prefix
If it points to /usr, either use sudo deliberately or change the prefix to a user-writable directory:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Then reinstall the global package:
npm install -g pnpm
Do not change ownership of /usr/lib/node_modules to your user account. That may solve the immediate error, but it weakens system package integrity and can interfere with future DNF upgrades.
npm ERR! code ERESOLVE
Dependency resolution errors are common when a project uses older dependencies or has conflicting peer dependencies.
First, update npm itself if appropriate:
npm install -g npm@latest
Then inspect the error carefully. The useful part is usually near the bottom, where npm identifies the conflicting package and required version range.
For legacy projects, --legacy-peer-deps can be a temporary workaround:
npm install --legacy-peer-deps
Use it as a diagnostic step, not a permanent solution. The real fix is usually updating dependencies, aligning peer dependency versions, or correcting a package constraint.
Native modules fail to build
Packages such as bcrypt, sqlite3, canvas, sharp, and some database drivers may compile native code during installation. If the build fails, install the compiler toolchain and relevant development headers.
sudo dnf install -y gcc gcc-c++ make python3
For packages that require additional system libraries, install those libraries through DNF rather than trying to solve every issue with npm. For example, canvas may require Cairo-related development packages, while database drivers may require client development libraries.
Check the package’s documentation before installing broad collections of development packages. Installing everything “just in case” creates a larger attack surface and makes the server harder to reproduce.
NodeSource and Fedora packages conflict
Symptoms include DNF reporting protected package conflicts, unexpected Node versions, or npm binaries disappearing after an upgrade.
Identify what is installed:
rpm -qa | grep -E '^nodejs|^npm'
dnf repolist
dnf list installed 'nodejs*'
If Fedora packages are installed and you want NodeSource to take over:
sudo dnf remove -y nodejs npm 'nodejs2*'
sudo dnf clean all
Then install NodeSource’s package:
sudo dnf install -y nodejs
If you want to return to Fedora-managed Node.js, remove the NodeSource repository configuration and reinstall from Fedora:
sudo dnf remove -y nodejs npm
sudo rm -f /etc/yum.repos.d/nodesource*.repo
sudo dnf clean all
sudo dnf install -y nodejs npm
Node process exits after reboot
A Node application started manually with node app.js will die when the SSH session ends or the server reboots. For production, use a service manager.
Create a systemd unit:
sudo nano /etc/systemd/system/myapp.service
Example:
[Unit]
Description=My Node.js application
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=nodeapp
Group=nodeapp
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=5
Environment=NODE_ENV=production
Environment=PORT=3000
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now myapp.service
sudo systemctl status myapp.service
Check logs with:
journalctl -u myapp.service -f
A process manager such as PM2 can be useful for developer workflows, but systemd is usually the better default on Fedora servers. It integrates with boot, logging, resource limits, and standard service management.