Jump to content

Node.js - React - Next.js

From Sinfronteras
Revision as of 11:25, 13 February 2026 by Adeloaleman (talk | contribs)

Node.js

On Ubuntu 25, the clean and reliable way to handle multiple Node.js versions is to use NVM (Node Version Manager).

 
18 (18.20.8)  LTS: Safe, widely compatible
20 (20.20.0)  LTS: Mature, very stable. A good choice today
22 (22.22.0)  LTS: Also stable. A good choice today
24            LTS: Early adopter / forward-looking

Install NVM

curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh  | bash  # Lasted
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash  # If you want a specific version
source ~/.bashrc
nvm -v
nvm install 18             # Install multiple Node versions
nvm install 20.20.0

nvm ls                     # List versions
nvm uninstall 20.20.0      # Remove versions

nvm alias default 20.20.0  # Set a default
nvm use default            # Set the one used on the current terminal

nvm use 18                 # Switch versions
nvm use 20.20.0

Per-project version. Inside a project directory:
cd mi_proyecto
echo "20.20.0" > .nvmrc
nvm use
npm install
npx create-next-app@latest 
npx create-next-app@14.2.5

npm uninstall @mui/material

To recreated node_module:
rm -rf node_modules
rm package-lock.json (only in some particular cases)
npm install


To run the NextJS app:  
npm run dev
npm run dev -- -p 3000 

To check unused and missing we can use:
npx depcheck


package-lock.json

  • Records the exact dependency tree that was installed: Exact versions (no ranges), Exact sub-dependencies, Resolved URLs, Integrity hashes
  • So, when you run npm install: npm does not guess - npm recreates the same tree every time.
  • So, package-lock.json exists to: Prevent dependency chaos, Make builds reproducible, Save you from random breakage