Vladimir Tagai
Vladimir Tagai

Reputation: 331

Change the system version of nodejs - ubuntu

I just started to use node.js in local projects few days ago. My application works good, if I run it from command shell

nvm run 0.10.32 ./bin/www app

or

node ./bin/www app

So, it works with node version 0.10.xx or higher. But there is a problem: I can't debug it from WebStorm - it throws lots of errors. I went to settings and was stunned: "Node.js core modules version is 0.6.12". Then, I've checked the installed versions of node and it returns

user@user-VirtualBox:~/$ nvm ls

-> v0.10.24 v0.10.32 system

and when I type

nvm use system

it says,

/home/user/.nvm/*/bin removed from $PATH
/home/user/.nvm/*/share/man removed from $MANPATH
/home/user/.nvm/*/lib/node_modules removed from $NODE_PATH
Now using system version of node: v0.6.12.

Obviously, I need to change the system version of nodejs. I tried to update, remove, reinstall - no results, it still has this version. All I need is being able to debug my application code from webstorm. How can I get it - change system version of node, or maybe another ways? Any tips would be very helpful.

Upvotes: 12

Views: 14493

Answers (3)

KnowsCount
KnowsCount

Reputation: 327

a not quite sustainable solution is simply create symbolic links:

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm"

Upvotes: 0

Fernando Cea
Fernando Cea

Reputation: 267

You must install the version you need:

nvm install x.y.z

and then define the alias for that version:

nvm alias default x.y.z

Note: you must restart (close and reopen) your terminal in order to have the changes applied.

Upvotes: 1

FGRibreau
FGRibreau

Reputation: 7239

Verify that default node is really coming from nvm with which node, if its not, you can safely run :

rm `which node`

To set the default node version with nvm use :

nvm alias default 0.10.32

If you have many apps that use different node version, add a .npmrc in the root directory in each of them. .npmrc only contains the version, e.g. "v0.10.32".

Then each time you cd into a project run

nvm use

Upvotes: 15

Related Questions