Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch Nodejs Version of root user?

I am facing a problem as posted here, and notified that the cause may be the version of nodejs.

As shown below, the node version is fine.

$node -v
v7.2.0

But it gives me an abnormal version of the root user, which is used by crontab process.

$sudo su
$node -v
v0.10.42

I've tried $n rm 0.10.42 or $n 7.2.0 many times won't fix the problem

Can someone help? I want the crontab process to use the correct version of nodejs.

like image 815
Jacky Lau Avatar asked Nov 24 '16 01:11

Jacky Lau


1 Answers

I find out that I can simply add the correct which node path to $PATH.

$which node
/usr/local/bin/node
$sudo su
$which node
/usr/bin/node
$export PATH=$PATH:/usr/local/bin
$node -v
v7.2.0
like image 196
Jacky Lau Avatar answered Sep 24 '22 01:09

Jacky Lau