"node -v" shows wrong version after "brew upgrade node" - node.js

I upgraded my version of Node.js with brew upgrade node which installed v5.3.0. But when I get the version of node with node -v it shows v0.10.29.
I tried brew link --overwrite node but that didn't work.
Brew has node linked to /usr/local/Cellar/node/0.10.29 so I went there and noticed that there are other versions of node including the version I want in /usr/local/Cellar/node/.
How do I tell brew to link node to /usr/local/Cellar/node/5.3.0 ?

Try to brew link --override node
Also see related question How to install latest version of Node using Brew.

I removed the other versions of node that I didn't want in /usr/local/Cellar/node/ and then ran :> brew unlink node && brew link node and it fixed the problem.

Related

How to downgrade node version?

I want to downgrade my version using npm.
The current version is 16.13.1. I want to downgrade this to 12.0.1. Can anyone tell me how to do it?
Thanks!
use node version manager nvm, you can switch any node version that you want.
More details
https://github.com/nvm-sh/nvm/blob/master/README.md
https://www.npmjs.com/package/nvm
nvm install 14.15.5
nvm use 14.15.5
Use below command for all installed node versions
nvm list
You can accomplish that with Node Version Manager. Install nvm first, and in a terminal:
nvm install 12.0.1
Then
nvm use 12.0.1
You can use: npm install -g node#version.
So for example in your case it would be -> sudo npm install -g node#12.0.1
might have to force it with --force at the end.
You could also install the node npm module to change (upgrade or downgrade) the NodeJS version for the specific project.
Try the n package from npm. Find it here.
npm install -g n
n 10.16.0
n lts
Simply execute n <version> to download and install a version of Node.js. If has already been downloaded, n will install from its cache.
first check your node version
node -v
sudo npm install -g n
sudo n stable
sudo n 14.6.0 (you can chnage version here as you want to move)
npm install (jst run after all)
now you can check the node and npm version by
node -v
npm -v
Clearing the local installation of node, to find out where is and delete
where node
Install nvm
For Windows
For others
Show all the versions
nvm ls available
Install what you want
nvm install 12.0.1
nvm use 12.0.1
Check node version
node -v
I have tried several ways and this works, hope it helps.
I finally found a simple solution.
Uninstall the current Version
Download the version you want.
It works fine for me.
Thanks!

Unknown error: SyntaxError: Unexpected token 'export' on ng command

I'm trying to learn Angular
I've followed the steps here: https://angular.io/guide/setup-local to get it setup on Ubuntu 18.04.5 LTS
When I try to create a new project with ng new I get an error:
$ node -v
v14.12.0
$ npm -v
6.14.8
$ ng new test
Unknown error: SyntaxError: Unexpected token 'export'
$ ng -v
Unknown error: SyntaxError: Unexpected token 'export'
I installed it via sudo npm install -g #angular/cli which gave no errors.
I've purged node sudo apt-get purge nodejs and reinstalled and removed ng sudo npm remove -g #angular/cli then reinstalled again sudo npm install -g #angular/cli, still get this error. Any ideas?
There was an older version of nodejs on the system originally; I upgraded to 14.x. Export is part of ES6, perhaps it's related? I can't seem to figure it out.
I had the same issue and I could fix it by downgrading node to v12.8.1
You could use nvm as follows:
install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
refresh .profile
source ~/.profile
install node v12.8.1
nvm install v12.8.1
check that you are using the 12.8.1 version
nvm list
check ng again
ng -- version
You are using an incompatible NodeJs version. Install a lower version.
More information here (webarchive version).
Check for node versions.
use nvm
brew install nvm
I had the same problem. if you have any other version of Node that might fix it
On the Angular Github
node requirement is below
"engines": {
"node": ">=10.13.0 <13.0.0",
"yarn": ">=1.22.4"
}
after installing the older version
nvm install 12.4.0
then
nvm use 12.4.0
this did the fix for me
For me no solution worked so I uninstalled everything, both the angular and node cli, thinking that it was a version error, but when I typed ng in the console, the error kept appearing so I found where ng was, with whereis ng, delete the file and install all over again.
Run the following command on cmd. This recommends that you always update to the latest patch version, as it contains fixes we released since the initial major release. For example, use the following command to take the latest 10.x.x version and use that to update.
ng update #angular/cli#^<major_version> #angular/core#^<major_version>
First of all Don't run any command which is collected from here and there. Simply follow these steps.
1 uninstall current NodeJS version
2 download lowest version from here.
3 install the lower NodeJS version.
4 restart cmd Promat/terminal and try.
This worked for me.
Have encountered this error many a times in past.
What worked for was removing the package.lock and node_modules & rerun the npm install.
cached code might be causing the trouble.
Install a newer node version and also reinstall angular. For me it did not work with only installing a newer node.

Used brew to install node, when checking node version, says not installed

I have tried uninstalling node with brew and reinstalling. I get a link error and when I check what version of node I have installed with node -v, it says node is not installed. What could be going on?

Updating Node and NPM

On a Mac OSX, I want to update to the latest versions of node and npm which is currently v10.7.0
I installed homebrew and executed the following at the terminal.
brew update
brew upgrade node
Now, when I type
node -v
the terminal responds:
v6.10.2
And when I type
npm -v
the terminal responds:
6.2.0
It looks like I have earlier versions of Node.
But when I type
brew upgrade node
The terminal responds with
node 10.7.0 already installed
It looks like there's a discrepancy. On one hand, it's telling me I have an earlier version of node. On the other hand, it's telling me I have the latest version.
What can I do to install and get my machine to recognize the latest node version?
You probably need to link the new version using brew link node or brew link --overwrite node
I have been using nvm on my linux servers for a while and now prefer to use it (over homebrew) on my development mac as well -
curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Now just open a new shell (or source ~/.nvm/nvm.sh) and switch to whichever version you would like. Eg.
nvm install 10.7.0
nvm use 10.7.0

How to remove older version of Node and switch to new version?

When I node -v I get v7.10.0
I've installed with brew install node and brew upgrade node I see that 9.5 got installed.
I did brew switch node 9.5.0 and got 7 links created for /usr/local/Cellar/node/9.5.0
However when I reopen the terminal my node -v is still v7.10.0 :(
Found the answer here, I needed to remove my .nvm folder
Unable to change version of node with brew switch
First of all, check if you installed your node with nvm by check if you have a .nvm directory in home directory ls -la
if you do, remove that directory

Resources