DEV Community


Posted on


How to manage your Node.js version on Replit

How to manage your Node.js version on Replit

  1. First, go to Replit and create a REPL. Select BASH and NOT Node.js (We'll install it later). Funnily enough, at the time of writing, if you ran node -v, you would see v14.17.1 (which is an LTS version, and also considering we didn't install Node).
  2. Select Shell (which is just beside Console)
  3. Copy and paste the following code below into Shell. On Windows, it's Ctrl+Shift+V. You can change the 16 below to any version you desire.
  curl -o- | bash
  export NVM_DIR="/config/nvm"
  [ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  nvm install 16 
  nvm use 16
Enter fullscreen mode Exit fullscreen mode
  1. Wait for a while. You may choose to go to the toilet or grab a few bites in the meantime.
  2. After the code below has finished running and installing Node.js, run node -v && npm -v. You should see an updated Node.js (v16.x.x) and NPM (v8.x.x at time of writing) version.
  3. Run the following to test:
 echo console.log(`Node version: ${process.versions.node}`) > test.js
 node test.js
Enter fullscreen mode Exit fullscreen mode

You should now see an updated/different Node version, depending on which version you installed and used earlier on.

That's it! You can now install and use any Node.js version you wish!

Post was last updated on 10/10/2021

Top comments (0)