Ron I
Ron I

Reputation: 4250

Updating Node issue

I am trying to update to version 6.2.2 of Node, and tried the instructions in this SO answer, however, I am still getting v.0.12.4 when I type node -v.

Below are the steps I took and the output:

~ sudo npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
 ~ sudo npm install -g n
/usr/local/opt/nvm/versions/node/v0.12.4/bin/n -> /usr/local/opt/nvm/versions/node/v0.12.4/lib/node_modules/n/bin/n
[email protected] /usr/local/opt/nvm/versions/node/v0.12.4/lib/node_modules/n
 ~ sudo n stable
 ~ node -v
v0.12.4
 ~ sudo n 6.2.2
 ~ node -v
v0.12.4

When I tried to upgrade node with brew I got the following:

 ~ brew upgrade node
Error: node 6.2.2 already installed

I'd like to make sure that my app is using version 6.2.2 only (happy to get rid of the older one). When I run npm start on my app, I get an error for using ES6 syntax:

/Users/.../modules/edu.js:28
let x=2;
SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)

Any help is appreciated!

Upvotes: 0

Views: 509

Answers (2)

Ron I
Ron I

Reputation: 4250

I updated nvm using:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash

Source: https://github.com/creationix/nvm/blob/master/README.markdown

And it's using the latest version of node now. Please note it gave me the path to the directory I needed to delete in order for the curl to work when I tried to run it the first time, and I had to rebuild an npm package (which I discovered when I tried to run gulp)

Upvotes: 0

Cameron637
Cameron637

Reputation: 1719

I had this issue before and realized that I had node installed in two different locations on my computer. The one that the command line was getting its version output from was not the one I had just installed. I fixed it by ensuring specified the installation path to same place where the command line was reading the version. For me, on Windows 10, it was reading it from the Program Files (x86) folder instead of the regular Program Files folder where node kept installing to. Check your drive to see if you have any other places where node could be installed globally and then if so you can specify the installation path to that folder.

Upvotes: 1

Related Questions