Upgrade the version of nodejs to 5.12.0 - node.js

I tried to install node.js by NVM in Ubuntu 16.04 server by following this link. And I got:
root#instance-15s8fbzx:/opt# nodejs --version
v4.2.6
root#instance-15s8fbzx:/opt# npm --version
5.3.0
root#instance-15s8fbzx:/opt# node --version
v8.4.0
Then, we I run a mean-stack project by sudo npm start, I got
class User {
^^^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
Then, I saw this link, I think maybe because the nodejs version is not correct. I have another server with v5.12.0 as the version of nodejs, and the project worked well there.
Then, I tried to do
sudo npm install -g npm
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/8.4.0/bin/node /usr/bin/node
But the version of the nodejs is still 4.2.6. Does anyone know how to upgrade its version to 5.12.0?

After you have installed NVM and you have installed the necessary version of node, you select the node version as follows:
> nvm use v5.12.0

After upgrading to the Nodejs version, the following error occurred for the Laravel and VUE js packages I already had:
PHP Fatal error: During inheritance of IteratorAggregate: Uncaught
ErrorException: Return type of
Symfony\Component\HttpFoundation\ParameterBag::getIterator() should
either be compatible with IteratorAggregate::getIterator():
Traversable, or the #[\ReturnTypeWillChange] attribute should be used
to temporarily suppress the notice in
C:\xampp\htdocs\clerk\vendor\symfony\http-foundation\ParameterBag.php:210
To solve the issue, I did the following:
composer update
npm update
npm run dev
php artisan serve

Related

npm does not support Node.js v14.4.0

everyone.
I am upgrading Node.js and npm in my Ubuntu 18.04.6 server, but I'm running into a strange problem.
I was using the process as indicated in the installation guides:
To install Node.js version 17.2.0, I use
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs
Then, to install npm version, I use
npm install -g npm
However, after this, when I try to use npm to install modules, I get the warning
npm does not support Node.js v14.4.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
Checking the versions of node, I find that
node --version
yields v14.4.0, but
nodejs --version
yields v17.2.0.
How do I fix it so node will point to the latest version and/or so npm will use the correct version of node?
I had also tried a lot for upgrading node version from 14 to 18. But even after installing latest version and following various procedures my version of node was showing 14.4.0 only.
Luckily following three node version manager commands solved my problem on my ubuntu machine v20.04.4:
1. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
2. command -v nvm
3. nvm install node
Now check node has been updated to latest version and can be verified with node --version.
If you still find an old version even on installing new latest/lts version, then check which node version is set as default with following command:
nvm ls
you will see green colored version text set with an arrow in front of it. It will also show other versions which have installed recently like v16.15.0, v18.2.0, etc.
Change the node version you want to set by following command:
nvm alias default v18.2.0
After this close the terminal and restart the new terminal and try checking node JS version. Here you got you want..!!

Installed ES Lint globally but getting error -bash: eslint: command not found

I am on a mac using Catalina.
I installed ES Lint globally using
npm install -g eslint
the output says
/usr/local/opt/nvm/versions/node/v10.13.0/bin/eslint -> /usr/local/opt/nvm/versions/node/v10.13.0/lib/node_modules/eslint/bin/eslint.js
+ eslint#7.10.0
However I am confused because I made sure to use nvm uninstall node v10.13.0. Then I downloaded the latest install from the node website and installed it.
when I do node -v I get
v12.18.4
Why is it still installing ESlint it to the old 10.13.0 directory?

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.

How to upgrade angular-cli on Linux? Node.js V6.14.3 not supported by CLI v6

Whenever I enter ng in termial, it outputs
You are running version v6.14.3 of Node.js, which is not supported by
Angular CLI v6. The official Node.js version that is supported is 8.9
and greater.
Please visit https://nodejs.org/en/ to find instructions on how to
update Node.js
How to fix this issue?
This happens only in non root user account, works fine with root account
Your error message indicates, that your node version is not supported by angular.
So you should rather update node.
The current LTS is 8.11.3 which you can download here:
https://nodejs.org/en/
I've been using 'nvm' for this, it is a node version manager that allows you to install and switch between node versions very easily.
You can find it here:
https://github.com/creationix/nvm/blob/master/README.md
I was using nodejs v4.2.6 and npm v3.10.10
When I ran npm install -g #angular/cli, I think it tried to install latest version of angular-cli, hence I was getting this error.
You are running version v6.14.3 of Node.js, which is not supported by Angular CLI v6. The official Node.js version that is supported is 8.9 and greater.
Due to some reason, I didn't wanted to upgrade to latest node and npm packages, so I resolved it by npm install -g #angular/cli#1.1.1
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use:
sudo n latest
To undo:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node
sudo n rm 6.0.0 # replace number with version of Node that was installed
sudo npm uninstall -g n
Found in David Walsh blog

what is the difference between node and nodejs

After installing node via npm , using 'nvm ls' gives the version which i have installed like v8.9.4 and also node -v also shows the version. But at the same time, when checking for 'nodejs --version' tells me to install node js as 'sudo apt-get install nodejs'.
Via npm or nvm Node.js is called node but if you install via apt-get you need to use the package name nodejs because via apt-get node is a package name take by a completely different application that happens to also be called node.
what are the differences between node.js and node?

Resources