Gizmo Tales

Gizmo Tales

How to use Node.js V16.x On Replit!

How to use Node.js V16.x On Replit!

Guide To Use Node.js v16.x in repl.it

Subscribe to my newsletter and never miss my upcoming articles

In This Guide we'll go through a step by step process On How To use Node.js v16.X on replit.com

  1. Execute this script on the shell to install node and configure npm.
npm i --save-dev node@16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH

Output: image.png

And execute this to clean npm cache and reinstall the package.

rm -rf node_modules && rm package-lock.json && npm cache clear --force && npm cache clean --force && npm i

Output: image.png

  1. Create the .replit to execute node from the shell instead of the console.
run="npm start"
  1. Make sure to add the start script in your package.json file
 "scripts": {
    "start": "node index.js"
  }
  1. Check Node Version:
    node -v
    

Output: image.png

  • You can also add all of it, in your package.json
"scripts": {
  "start": "node .",
  "node-update": "npm i --save-dev node@16 && npm config set prefix=$(pwd)/node_modules/node && export PATH=$(pwd)/node_modules/node/bin:$PATH",
  "node-clean": "rm -rf node_modules && rm package-lock.json && npm cache clear --force && npm cache clean --force && npm i",
  "node-update-then-clean": "npm run node-update && npm run node-clean-cache"
}

then run

npm run node-update-then-clean
  1. (Optional) If you had packages like canvas or sqlite before, you need to re-install those packages
npm uninstall canvas && npm i canvas

Q: Does node version reset after you leave exit the repl or the repl restarted?

  • A: No, when you check your node version in shell, it will still v12, but when you run your repl then console.log the process.version it will log the v16.

Q: Why it still log the node v14?

  • A: If your using the repl bash, use the repl nodejs.

Stay Connected:

  • Join My Discord Server If you need help!

 
Share this