user1658162
user1658162

Reputation: 2821

Cannot upgrade Node.js using n

I'm trying to update Node.js on Ubuntu serever 14.04 using n. n upgrades but the version is still the same:

root@0e2dbaa3db85:/home# node -v
v0.10.25

root@0e2dbaa3db85:/home# n 0.10.33
  install : node-v0.10.33
    mkdir : /usr/local/n/versions/node/0.10.33
    fetch : https://nodejs.org/dist/v0.10.33/node-v0.10.33-linux-x64.tar.gz
installed : v0.10.33

root@0e2dbaa3db85:/home# node -v
v0.10.25

Do I have to tell n which version to use as default?
I've tried n latest, it installs 0.12.0 but node -v outputs 0.10.25 again.

What should I do?

Upvotes: 3

Views: 10948

Answers (8)

qualbeen
qualbeen

Reputation: 1582

I faced a similar issue, caused by Homebrew. I did not install Node by Homebrew by choise, but I had recently installed a MongoDB-package through Homebrew (mongodb-community). Node is aparently bundled with that package 😉.

Solution: Uninstall Node through Homebrew, letting the 'n' software do the job!

$ brew uninstall --ignore-dependencies node
$ sudo n 18

(Replace the number 18 with whatever specific version you need to target)

$ node -v
v18.20.5

Upvotes: 0

Jonathan Bird
Jonathan Bird

Reputation: 352

For me, I had the active version set via Homebrew, so n wasn't overriding it.

I had to use the following:

brew uninstall node && sudo n stable

Upvotes: 0

Spiff Jekey-Green
Spiff Jekey-Green

Reputation: 327

I faced same issue, where I select a different version or even download a new version with n and it still shows the initial installation before I started using n. This worked for me:

  1. Unlink

    sudo unlink /usr/bin/node

  2. Run n again to choose the node version. After this two steps it worked

Upvotes: 2

rafwell
rafwell

Reputation: 499

Try to set the simbolic link to node to the npm global folder.

  1. sudo unlink /usr/bin/node
  2. sudo ln -rs PATHTO/.npm-global/node/bin/nodee node

in my case, my path to npm-global dir was on my home. So the full path was /home/rafael/.npm-global/node/bin/node

After this, check if is allrigth:

  1. node -v //return current node version
  2. n stable //install the stable current version
  3. node -v //will return the new version installed
  4. n 8 //install the version 8 for test
  5. node -v //will return the 8 version

Enjoy

Upvotes: 0

Tung Nguyen
Tung Nguyen

Reputation: 855

  • Resolved by nvm.
  • I faced the same issue with you. I could not change node version with n because I installed nvm and used nvm to manage node versions before.
  • I resolved the issue by execute nvm command. For example: nvm install 11.8.0 then check node version node -v. Tada it works.

Upvotes: 8

The Lazy Coder
The Lazy Coder

Reputation: 11838

On occasion the n package won't install the links for node, and the selection won't allow you to select any version installed by n.

When that happens, you need to install an "n" version of node so the selector will allow you to choose.

Here is what I had to do.

  1. Use n to install a node version.

    # n stable
    
     install : node-v5.10.1
       mkdir : /usr/local/n/versions/node/5.10.1
       fetch : https://nodejs.org/dist/v5.10.1/node-v5.10.1-linux-x64.tar.gz
    ######################################################################## 100.0%
       installed : v0.10.42
    
  2. Select the node version from the install directory
    In this case it is located at:

    /usr/local/n/versions/node/5.10.1/bin/node
    
  3. Replace existing node link with new node version

    cd /bin
    mv node node_old
    ln -s /usr/local/n/versions/node/5.10.1/bin/node
    

At this point node should work, and n should allow you to select version.

Upvotes: 10

gustavohenke
gustavohenke

Reputation: 41440

From what I can read from the n readme, you need to call n <version> to install, and then run n with no arguments, so a version picker will be shown:

Type n to prompt selection of an installed node. Use the up / down arrow to navigate, and press enter or the right arrow to select, or ^C to cancel:

(...)

Commands: n <version>    Install node <version>

However, if you run n latest, it will install or activate the latest version:

n latest            Install or activate the latest node release

Upvotes: 0

Andr&#233; Dion
Andr&#233; Dion

Reputation: 21748

n 0.10.33 will install that version of node, but you still haven't selected it. After installing, simply execute n and pick the version you want to use.

n latest will install or activate the latest version of node. Run it twice to use node 0.12.0

Documentation.

Upvotes: 2

Related Questions