How to manage your Node.js version on Replit
- 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 seev14.17.1
(which is an LTS version, and also considering we didn't install Node). - Select
Shell
(which is just besideConsole
) - Copy and paste the following code below into
Shell
. On Windows, it'sCtrl
+Shift
+V
. You can change the16
below to any version you desire.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
export NVM_DIR="/config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 16
nvm use 16
- Wait for a while. You may choose to go to the toilet or grab a few bites in the meantime.
- 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. - Run the following to test:
echo console.log(`Node version: ${process.versions.node}`) > test.js
node test.js
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)