Skip to content
← Back to Community
change node version
Profile icon
andreebr

Can I change the node version of a repl?

Answered by Mosrod [earned 5 cycles]
View Answer
Voters
Profile icon
NeerajSewani
Profile icon
MasterCum
Profile icon
OhhgodYes
Profile icon
none1511
Profile icon
patriciocarvalh
Profile icon
ElektrodemonNL
Profile icon
DrevennAgiota
Profile icon
KookieHope
Profile icon
SahilDahat
Profile icon
eastseasts
Comments
hotnewtop
Profile icon
Mosrod

You cannot modify a language's version on repl.it if it does not have a separate language for the version (e.g. Python 3&2).

Profile icon
ash15khng

@Mosrod @andreebr adding on to this you could copy and paste your code into another repl with the correct version, however it may be tedious if you have multiple files.

Profile icon
andreebr

@ash15khng I couldn't find a way to create a node repl on a diferent version (sorry for the late response =S)

But thanks anyway =D

Profile icon
ash15khng

@andreebr Actually, if you check out repl.it/languages there seems to be only 1 version of node.js currently supported on repl.it.

Profile icon
sinclairzx81

@ash15khng repl.it seems to be running different versions of node for different environments. As of writing..

NodeJS -> v10.16.0
TypeScript + NodeJS -> v9.11.2

It would be good to be able to set the NodeJS runtime, or perhaps use the current LTS for all node runtimes. repl.it is a pretty good way to communicate repros for developers tho, it would be better to able to select the appropriate runtime if possible.

Profile icon
lurking11

i would love to use nodejs 14 here , :) but i think it's not possible yet!

Profile icon
Looky1173

@lurking11 Hey, it's possible now! In fact, thanks to Nix, every programming language is now supported by Replit. Please read the following article for details:https://blog.replit.com/nix

Profile icon
joe64

To use Node.js version 16, just add this to a file called replit.nix:

{ pkgs }: { deps = [ pkgs.nodejs-16_x ]; }

and then add this to a file called .replit:

run = "node index.js"

and then add your code to index.js.

Profile icon
CrazyVideoGamer

Actually, you can change the node version. Here I'm going to use nvm. My script for installing it and setting it up is right here:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash # Don't copy + paste this export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" nvm install --lts nvm use --lts tput setaf 6; printf "\n\n" printf "If running node/nvm doesn't work, run:\n\n" tput setaf 2; printf 'export NVM_DIR="$HOME/.nvm" &&\n' printf '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&\n' printf '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" &&\n' printf '\nnvm install --lts &&\nnvm use --lts\n' tput setaf 6; printf '\nOr, just copy and paste the commands inside the script.\n' tput init # Copy + paste this, without the : ' and the ending quote : ' export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" && nvm install --lts && nvm use --lts '

This will install the lts version, but you can change that to be a different version (using nvm install 14.15.4 if you want 14.15.4, and then running nvm use 14.15.4 to use the 14.15.4 version). By the way, this is assuming the code is contained in use_nvm.sh (so the echo at the end is correct). To run the code (again assuming it is stored in use_nvm.sh), just run bash use_nvm.sh
Note: You must run this every time you reopen the repo.
By the way, you can also go to my repo here https://repl.it/@CrazyVideoGamez/Update-Node-Script#update_node.sh, and fork it.

Profile icon
theflowingsky

Sorry to bump an old thread but is this possible yet?

Profile icon
joe64

@theflowingsky You can do it using Nix. Just fork this, since it already has the config for Node.js v16:

https://replit.com/@ConnorBrewster/Nodejs-16

Or just add this to a file called replit.nix:

{ pkgs }: { deps = [ pkgs.nodejs-16_x ]; }

and then add this to a file called .replit:

run = "node index.js"

and then add your code to index.js.