I need to run a node script that requires a node version greater than 4.3.0. When I try to run the script something goes wrong, i.e. part of the output:
WARN engine enhanced-resolve@3.1.0: wanted: {"node":">=4.3.0 <5.0.0 || >=5.10"} (current: {"node":"4.2.6","npm":"3.5.2"})
WARN engine loader-runner@2.3.0: wanted: {"node":">=4.3.0 <5.0.0 || >=5.10"} (current: {"node":"4.2.6","npm":"3npm WARN lifecycle utf-8-validate@3.0.1~install: cannot run in wd %s %s (wd=%s) utf-8-validate@3.0.1 prebuild-install || node-gyp rebuild /home/diego/work/creditgate24/kloten-tegel/tegel/tegel/node_modules/utf-8-validateI thus checked the current version:
$node -v
v4.2.6but if I run:
$nvm ls v7.4.0
-> system
node -> stable (-> v7.4.0) (default)
stable -> 7.4 (-> v7.4.0) (default)
iojs -> iojs- (-> N/A) (default)I am new to node and nvm. Which version I am actually running? If 4.2.6 how could I upgrade it? thanks
1 Answer
Your current version is v2.4.6.
Here are the steps to upgrade via npm:
Clean Cache Fully
username@pcname:~$ sudo npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
Install n Module
username@pcname:~$ sudo npm install -g n /usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n n@2.0.2 /usr/local/lib/node_modules/nInstall Latest Release of Node
username@pcname:~$ sudo n stable install : node-v6.0.0 mkdir : /usr/local/n/versions/node/6.0.0 fetch : ############################################################ 100.0% installed : v6.0.0Setup Binary Link – Now link your node binary with latest node installed binary file using following command.
username@pcname:~$ sudo ln -sf /usr/local/n/versions/node/6.0.0/bin/node /usr/bin/nodeCheck your version of node - Should be latest version.
username@pcname:~$ node -v v6.0.0
You should now be able to run your script.