How To Install ReactJS on Fedora 45

Install ReactJS on Fedora 45

Installing React on Fedora 45 is mostly an exercise in choosing the right Node.js line. React is a library from npm and needs no system package. Fedora 45 changed how Node.js is packaged, so the choice you make in the first five minutes affects you for the next two years. This guide covers that choice, the project scaffold, and the production steps (Nginx, SELinux, firewalld, TLS) that tutorials usually skip.

Why Fedora 45 Needs a Little Thought

Fedora 45 shipped in early November 2026. The release notes describe a new Node.js packaging layout with two use cases. The unversioned nodejs package gives you a “recommended” version that stays stable within one Fedora release but may jump to a new major version during a system upgrade. A versioned package such as nodejs24 is guaranteed not to change across upgrades, though newer Fedora releases will eventually drop support for it. The French-language Fedora 45 announcement says the same: the unversioned metapackage is for users who don’t care much about the exact version, and the maintainers choose what it installs.

Here is the catch. One third-party test of Fedora 45 found that sudo dnf install nodejs pulls in Node.js 22, a line that now receives only critical and security fixes. The same source lists Node 24 as Active LTS and Node 26 as Current, with LTS starting in late October 2026. Treat those version numbers as a snapshot, because repositories move. Run dnf info before you trust any table, including that one.

React itself has no strict dependency on a distro. The build tooling is what needs Node. Vite, the tool most people now use to scaffold a client-side React app, requires Node.js 20.19+ or 22.12+. Both Node 22 and Node 24 on Fedora 45 clear that bar.

Pick a path before you type anything:

Scenario Recommended Node source Reason
Learning, quick prototypes dnf install nodejs24 Native, signed, updated with dnf upgrade
Several projects needing different Node versions fnm or nvm in your home directory Switch per project, no root needed
Production build server or CI Pinned versioned package or container image Reproducible builds
You need the newest Node release fnm or NodeSource Fedora’s packages may trail upstream

Prerequisites and a Quick System Check

Start with a patched system. Fedora moves fast, and a stale metadata cache is behind a surprising share of “package not found” complaints.

sudo dnf upgrade --refresh -y
cat /etc/fedora-release
uname -r

If the kernel was updated, reboot. It is a small habit that avoids chasing ghosts later.

Next, install the basic tooling. Git is nearly mandatory, and the compiler toolchain is needed because some npm packages still compile native addons.

sudo dnf install -y git curl wget gcc-c++ make python3

Check the resources too. A Vite dev server is light, but npm install on a large project can spike memory and disk use.

free -h
df -h /home
nproc

For a comfortable setup, aim for 4 GB of RAM and a few GB of free space. A 1 GB VPS can work, but add swap before running big installs.

Method 1: Install Node.js and npm with DNF

This is the simplest route and fits most developers on a workstation.

Check what the repository offers

dnf info nodejs
dnf list --available 'nodejs2*' 'nodejs-npm*'

You will see the metapackage and the versioned packages. The third-party test mentioned above found nodejs22, nodejs24 and, on Fedora 45 only, nodejs26. Your output is the authority here.

Install a versioned package

Pin to a major line instead of the unversioned metapackage. The reason is predictability. The unversioned package is allowed to change major version across a Fedora upgrade, and a build tool that quietly jumps from one major version to another is a bad surprise on a Monday morning.

sudo dnf install -y nodejs24
node -v
npm -v

If npm -v reports “command not found”, search for the npm subpackage and install it. Packaging details vary slightly between Node lines, so check rather than guess:

dnf search npm | grep -i nodejs

The Fedora package page for Node 22’s npm shows a nodejs-npm build (version 10.9.8) that depends on the matching nodejs package. Similar subpackages exist for the other lines.

Why not just run dnf install nodejs?

You can, and for a throwaway laptop it is fine. On anything you will maintain, the versioned package is the safer option. The unversioned metapackage’s whole job is to follow whatever Fedora’s maintainers consider recommended, and that can change.

Method 2: Use a Version Manager (fnm or nvm)

Anyone who juggles client projects knows the pain. One app needs Node 20, another wants 24, and a third breaks on anything newer than 22. A version manager solves it, and it keeps global npm installs inside your home directory, which also avoids permission headaches.

The third-party Fedora guide recommends fnm or NodeSource when you need a newer release than Fedora packages, because Fedora’s nodejs26 had fallen well behind upstream when it was tested. fnm is a single binary, so the install is short:

curl -fsSL https://fnm.vercel.app/install | bash
source ~/.bashrc
fnm install --lts
fnm default lts-latest
node -v

Piping a script to bash deserves a pause. Read it first with curl -fsSL https://fnm.vercel.app/install | less if the machine matters. On a production host, skip this method entirely and use a pinned package or container.

To make a project select its own version, drop a .nvmrc or .node-version file in the repository root:

echo "24" > .node-version
fnm use

Teams that commit this file avoid a whole category of “works on my machine” arguments.

Creating Your First React Project with Vite

The old standard, Create React App, is retired from the official recommendations. React’s current documentation points to frameworks first, with React Router mentioned as the most popular routing library and one that can pair with Vite for a full-stack setup. For building from scratch, the docs name Vite, Parcel and Rsbuild as build tools. For a client-side app on Fedora, Vite is the practical choice.

cd ~
mkdir -p projects && cd projects
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev

The extra -- before --template matters with modern npm. Without it, npm may swallow the flag and you end up answering prompts you didn’t expect. The same four-step flow is documented in common install guides, and the official React docs show the TypeScript variant, --template react-ts.

The dev server prints a local URL, normally http://localhost:5173. Open it in a browser and you should see the starter page with a counter button.

Which template should you pick?

  • react gives plain JavaScript and the smallest learning curve.
  • react-ts gives TypeScript, which pays off quickly on any project with more than one contributor.
  • Framework routes such as npx create-react-router@latest suit apps that need routing and server rendering from day one. Next.js offers a similar full-stack route via npx create-next-app@latest.

A good rule of thumb is that a dashboard behind a login is happy as a Vite SPA, while a public content site that needs search visibility usually benefits from server rendering through a framework.

Understand the generated structure

my-react-app/
├── index.html
├── package.json
├── vite.config.js
├── public/
└── src/
    ├── main.jsx
    ├── App.jsx
    └── assets/

index.html sits in the project root, not in public/. That surprises people coming from older tooling. Vite treats it as the entry point and rewrites script references during the build.

Accessing the Dev Server from Another Machine

By default Vite listens on localhost only. That is a sensible default, but it is a nuisance if you develop on a Fedora VM or a remote box and browse from your laptop.

npm run dev -- --host 0.0.0.0 --port 5173

Then open the port in firewalld, ideally temporarily:

sudo firewall-cmd --add-port=5173/tcp

Without --permanent, the rule disappears at the next reload or reboot. For a dev port, that is exactly the behavior you want. Never leave a dev server exposed to the open internet. It serves source maps and unminified code, and it was never designed to face hostile traffic.

Fixing Common Installation Errors

Real servers never behave like tutorials. These are the errors that show up most often.

Error: EACCES: permission denied on global installs

You tried npm install -g something with a system-installed Node, and npm attempted to write into a root-owned directory. Do not reach for sudo npm install -g. It leaves root-owned files in your cache and creates new problems later. Point npm at a user-level prefix instead:

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH=$HOME/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Or use fnm, which avoids the issue entirely. The Fedora guide mentioned earlier also covers fixing this error.

Error: Vite warns about Node version

If you see a message about an unsupported Node version, check node -v. Vite needs 20.19+ or 22.12+, and some templates may require more. An older Node from a stray installation earlier in your PATH is a frequent culprit:

which -a node
echo $PATH

Error: ENOSPC: System limit for number of file watchers reached

This one bites on larger projects. Linux limits inotify watchers, and the dev server uses many of them. Raise the limit persistently:

echo "fs.inotify.max_user_watches=524288" | sudo tee /etc/sysctl.d/99-inotify.conf
sudo sysctl --system

Keep an eye on memory. Each watch consumes a small amount of kernel memory, so a huge value on a tiny VM is not free.

Error: JavaScript heap out of memory during build

Large builds can exhaust Node’s default heap. Raise it for that command only:

NODE_OPTIONS="--max-old-space-size=4096" npm run build

If the build gets killed with no message, check dmesg | grep -i oom. The Linux OOM killer is probably the culprit. Adding swap is the cheapest fix:

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Fedora’s default install uses zram swap, so on a stock desktop this is rarely needed. Cloud images often differ.

Error: npm ERR! code ERESOLVE

Dependency conflicts happen when a library’s peer dependency range lags behind the React version. Read the error and see which package complains. Try updating that package first. Reaching for --legacy-peer-deps is acceptable as a stopgap, but record why you used it, because it hides real incompatibilities.

Error: blank page after deployment

The dev server works but the deployed build shows nothing. Open the browser console. Nine times out of ten the asset paths are wrong because the app is served from a sub-path. In Vite, set the base option in vite.config.js:

export default defineConfig({
  base: '/myapp/',
  plugins: [react()],
})

A similar symptom appears with other toolchains, where a missing homepage or base path produces a blank page after deploy.

Building for Production

Development servers are for development. Production gets a static bundle.

npm run build
ls -lh dist/
npm run preview

npm run preview serves the built output locally so you can sanity check it before shipping. It is still not a production server. The dist/ folder holds hashed filenames such as index-3f9a1c.js. Those hashes enable long-term caching, and that detail will matter in the Nginx section.

Serving React with Nginx on Fedora 45

Most React apps in production are static files behind a web server. Nginx handles that well and uses little memory.

sudo dnf install -y nginx
sudo systemctl enable --now nginx

Copy the build and set SELinux contexts

This is where Fedora differs from Ubuntu or Debian, and where many deployments quietly fail. SELinux is enforcing by default. Files copied into a web root with the wrong context return 403 errors, even when Unix permissions look perfect.

sudo mkdir -p /var/www/myapp
sudo rsync -a --delete dist/ /var/www/myapp/
sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/myapp(/.*)?"
sudo restorecon -Rv /var/www/myapp

If semanage is missing, install it:

sudo dnf install -y policycoreutils-python-utils

Never “fix” this by running setenforce 0 and moving on. Disabling SELinux to make one site work removes a layer of protection from every service on the host.

Write the server block

Create /etc/nginx/conf.d/myapp.conf:

server {
    listen 80;
    server_name example.com www.example.com;

    root /var/www/myapp;
    index index.html;

    gzip on;
    gzip_types text/css application/javascript application/json image/svg+xml;
    gzip_min_length 1024;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /assets/ {
        expires 1y;
        add_header Cache-Control "public, immutable";
        access_log off;
    }

    location = /index.html {
        add_header Cache-Control "no-cache";
    }

    add_header X-Content-Type-Options "nosniff" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
}

The try_files line is critical for single-page apps. When someone opens /dashboard/settings directly or refreshes the page, Nginx has no such file, so it falls back to index.html and lets the React router take over. Skip it and users see a 404 on every refresh.

The caching rules follow from Vite’s hashed filenames. Files in /assets/ can be cached for a year because a new build produces new names. But index.html must never be cached aggressively, or users will keep loading a page that points at old, deleted bundles.

Validate and reload:

sudo nginx -t
sudo systemctl reload nginx

Open the firewall

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

Add HTTPS

Browsers increasingly treat plain HTTP as a defect, and search engines favor HTTPS. Let’s Encrypt via Certbot is the usual route:

sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
sudo systemctl list-timers | grep certbot

Confirm renewal works with sudo certbot renew --dry-run. An expired certificate at 3 a.m. is an avoidable outage.

When Nginx proxies to a backend API

If the React app calls an API on a different local port, Nginx proxying keeps everything on one origin and avoids CORS pain:

location /api/ {
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
}

SELinux blocks this by default. Nginx is denied outbound network connections until you allow them:

sudo setsebool -P httpd_can_network_connect 1

A 502 Bad Gateway with a clean backend is the classic symptom. Check sudo ausearch -m avc -ts recent to confirm SELinux is the cause before changing anything.

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.

Related Posts