Can't install latest angular cli on ubuntu - node.js

I'm trying to install angular via ubuntu.
When I type the version commande node -v
I get v12.14.1
Then I try to install npm package sudo npm install -g #angular/cli
I get a warning
npm WARN npm npm does not support Node.js v10.15.2
ng version
I get angular-cli: 1.0.0-beta.28.3
The npm version is 6.13.4

The issue here seems to be that sudo node -v gives 10.15.2 where as node -v gives 12.14.1.
This means that there are 2 different node versions installed.
You can get around this by using sudo -E node -v or by deleting the link to the other node.js install by doing: rm /usr/local/bin/node.

Related

Failed to install Vue.js Cli

node -v: v8.10.0
npm -v: 3.5.2
While running npm install -g #vue/cli or sudo npm install -g #vue/cli I get the error below and failed to download Vue CLI
You are using a rather old version of npm. The current version is 6.9.0, and the packages you are working with are asking for npm >= 5.5.1.
You need to update your node version, if possible always use latest node version
Nodejs version 14.4.
And if you have project that required different node version then use
NVM - node version manager
Just use sudo for global install
sudo npm install -g #vue/cli

installed latest version of node -- but npm is broken (mac)

OK so, I went to the nodejs.org webpage, downloaded node version 7.5.0, installed it using the easy to use wizard.
It installed with no errors or issues.
When I open up my terminal, node -v gives me v7.5.0, and npm -v gives me 3.6.0.
Obviously I want the latest version of npm, so I go to npm install npm#latest -g, but I get this error:
Cannot find module 'internal/fs'
In fact, trying to install ANYTHING using npm results in the same error.
How do I fix npm?
Try uninstalling your current node version and reinstall using nvm or brew:
To find where node lives: command -v node && command -v npm
Remove these directories as stated in some of the comments here: https://github.com/nodejs/node/issues/9377
Posting this for anyone passing by. You can use npm up -g to update the npm version. Here's output from my console installing node 4.7.3 via nvm:
user#localhost:~/Desktop/demo$ nvm install 4.7.3
Downloading and installing node v4.7.3...
Downloading https://nodejs.org/dist/v4.7.3/node-v4.7.3-darwin-x64.tar.gz...
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v4.7.3 (npm v2.15.11)
user#localhost:~/Desktop/demo$ npm up -g
/Users/user/.nvm/versions/node/v4.7.3/bin/npm -> /Users/user/.nvm/versions/node/v4.7.3/lib/node_modules/npm/bin/npm-cli.js
npm#4.2.0 /Users/user/.nvm/versions/node/v4.7.3/lib/node_modules/npm
user#localhost:~/Desktop/demo$ npm -v
4.2.0
user#localhost:~/Desktop/demo$

npm update fires off successfully, but doesn't actually upgrade npm -v

This is on a Macbook
I execute sudo npm install -g npm and get this following output:
/Users/myUser/.npm-packages/bin/npm -> /Users/myUser/.npm-packages/lib/node_modules/npm/bin/npm-cli.js
npm#3.10.8 /Users/myUser/.npm-packages/lib/node_modules/npm
However, when I restart terminal and npm -v, I still get 2.15.9
The nvm tool is most commonly used for managing Node versions and upgrades. Follow the directions here for your platform: https://github.com/creationix/nvm

Node and NPM versions don't match

The node and npm versions on my mac dont match. How do I downgrade npm to the same version as node?
Node:
$ node -v
$ v0.12.7
NPM:
$ npm -v
$ 2.14.4
npm is a package manager for node.js. They don't have to be the same version. npm also gets updated more frequently than node, so they could not be expected to keep their versions the same
If it helps, you can install any version of NPM. On debian distros, to use npm version 4.5.0 you need to do:
$ curl https://registry.npmjs.org/npm/-/npm-4.5.0.tgz
$ tar -xvzf npm-4.5.0.tgz
$ cd package/
$ [sudo] make install
Their versions are different because they are independent softwares. Their development is not synchronized.
I recommend updating NPM when you can; I'm running npm version 5.2.0
You can easily upgrade your NPM version using npm install -g npm

Start with fresh copy of node, npm and cordova

I had a makeshift setup on Lubuntu that 'functioned' with sudo npm install. I used Ionic Framework generator to create projects and they functioned as well as the builds and deployment.
I upgraded to 15.04 and ever since had problems finding a solution that worked does not give EACCESS errors or grunt serve telling me
Upgrade warning - for the CLI to run correctly,
it is highly suggested to upgrade the following:
Please update your Node runtime to version >=0.12.x
Please update your Cordova CLI to version >=4.2.0 npm install -g cordova
then for npm install -g cordova to tell me
npm WARN engine cordova-serve#0.1.3: wanted: {"node":">= 0.12.0","npm":">= 2.5.1"} (current: {"node":"0.10.26","npm":"2.12.1"})
I have tried the "chown -R whoami /dir/of/npm"
I have delete npm, node install brew and created new installs for all.
I still get EACCESS errors, my yo ionic "grunt serve" deploys the browser but gives ERR_CONNECTION_REFUSED
I installed brew, manually deleted the npm folder and did a clean install. No joy
which node - /home/username/.nvm/v0.10.26/bin/node
node -v v0.10.26
which npm - /home/userna/.linuxbrew/bin/npm
npm -v 2.12.1
which cordova - /usr/local/bin/cordova
cordova -v 3.5.0-0.2.6
And for good meassure i thought if i installed node4 all my troubles would disappear.
I know i messed this up but i would like a clean start with node, npm(without sudo) and cordova. Any help would be appreciated
Ps: I have done most of the normal suggestions hence my question.
Did you installed node using nvm?
So try
nvm use 4.0.0
In general:
nvm install [VERSION]
nvm use [VERSION]
To use permanent:
nvm alias default [VERSION]
try also to install cordova again after updating node
npm install -g cordova
If all fails:
Uninstall node and reinstall propper using brew:
cd ~
sudo rm -rf .npm
brew update
brew uninstall npm
brew install npm

Resources