Error when I try to install npm on Ubuntu 17.04 - node.js

I'm trying to install npm on Ubuntu 17.04 but I'm not getting it. I've installed nodejs and nodejs-legacy and when I try to install npm, a message appears saying that npm depends on node-gyp (>= 0.10.9) and won't be installed. If a try to install node-gyp, another dependency appears and successively. Does anybody know how to fix it?

if you use apt-get for install nodejs you can switch version easily:
$ sudo apt-get install npm # install npm
$ sudo npm install -g n # install n nodejs version switcher as global package.
$ sudo n stable # install latest stable version.
install more version: [exmp: 9.1.0]
$ sudo n 9.1.0
reference

I suggest you don't use apt-install to install npm.You can download the bin file from official site.(https://nodejs.org/en/)
Just extract the tar file and setup the path to you system,you can get the latest version!

Related

I have try to install node js 4.3.2 version but it give error

sudo apt-get install nodejs=4.3.2
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '4.3.2' for 'nodejs' was not found
Do you specifically want to install version 4.? The newest available is 12..
For installation of a specific version use apt-get install package=version -V. If this does not work for you please provide more info about your linux distro & version. You can always download the right Version of node manually on nodejs.org. You could also build it yourself.
Also check version availability for your system with sudo apt policy nodejs
Either way, first remove the previous installation completele, using
sudo apt-get purge package_name
then try installing the current version with PPA, by first running
sudo apt-get update
sudo apt-get install nodejs
after that you can check the version with node -v and for npm with npm -v
Try installing NodeJS using NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
check NVM is installed properly
nvm --version
To install the latest stable version
nvm install stable
Or a specific version
nvm install 12.4.0
nvm install 4
To list locally available Node JS versions
nvm list
Switch NodeJS version
nvm use version
Eg : nvm use 4
To make nodejs available for all users
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
Or Install it manually by downloading
https://nodejs.org/dist/v4.3.2/node-v4.3.2-linux-x64.tar.xz

Installing latest version of npm on Ubuntu 14.04 (trusty)

I have
a remote serving running Ubuntu 14.04. I used apt to install node
a local OSx machine running El Capitan. I used hombrew to install node.
This results in the following.
Ubuntu 14.04
> sudo apt-get update
> sudo apt-get install node nodejs npm
> npm --version
1.3.10
> node --version
(emtpy)
> nodejs --version
v0.10.25
OSx
> brew install node
> npm --version
5.6.0
> nodejs --version
-bash: nodejs: command not found
> node --version
v8.11.3
Why are the apt repositories so out of date? The npm version on the server (1.3.10) is 4 versions behind that of OSx machin (5.6.0).
This npm issue even mentions that the apt repositories are quite old / not updated.
Is there a way to install a more recent version of npm on the Ubuntu server?
Download this tar file from nodejs official website
https://nodejs.org/dist/v8.11.4/node-v8.11.4.tar.gz
download, untar and install it via using the following command
sudo make test
sudo make install
It will install 8.11.4 version.
Please note that you can download any version of tar from nodejs officail page and can install it on your Ubuntu server and by using this method you don't need to update your apt packages.

How to install PhantomJS v2 with npm

I'm trying to install PhantomJS v2.0.0 using npm and after trying a couple of methods I've not found a working solution...
On NPM the latest version is 1.9.16, so I've tried the following in my package.json:
"phantomjs": "https://github.com/ariya/phantomjs/archive/2.0.0.tar.gz"
This gives me an error because there isn't a package.json for this version in the github repo.
"phantomjs": "2.0.0"
This tells me there is no version with this number available.
Am I missing something here?
phantomjs-prebuilt was renamed from phantomjs and now additionally contains binaries for version 2.1+.
npm -g install phantomjs-prebuilt
The fork phantomjs2 is still available which contains version 2.0.
npm -g install phantomjs2
Keep in mind that not all platforms might be supported.
Phantomjs may be installed as a brew package. Confirm this:
brew ls | grep phantomjs
If you do have phantomjs installed as a brew package, you can easily uninstall it:
brew uninstall phantomjs
Then try rerunning npm install after updating your package.json for "2.0.0".
FYI: Please read semantic versioning: https://stackoverflow.com/a/22345808/3412545
I had troubles to install it via npm.
I decided to build it. I'm running Ubuntu 15.10.
First, check you have all the development packages installed :
sudo apt-get install build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev
Then download the source code : https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-source.zip
And run :
cd phantomjs-2.0.0-source
sudo ./build.sh
It's a very long process to build it ! Be sure you know what you're doing.
npm install phantomjs-prebuilt try this for node users

Can't install Grunt on OSX 10.6.8

I'm new to this. I would like to use Grunt to run do some image optimalization. But I can't get it installed for some reason.
I've installed Homebrew by copying this in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I've also installed node on my system (by downloading the .pkg and installing it).
When I check if Homebrew and Node are installed I get this:
Joost:~ jvd$ which brew
/usr/local/bin/brew
Joost:~ jvd$ which node
/usr/local/bin/node
When I try to install Grunt by using this code: npm install -g grunt-cli i get (also when I use $ sudo)
Joost:~ jvd$ npm install -g grunt-cli
-bash: npm: command not found
Same goes for: npm update -g npm.
Like I said Im fairly new to this so most of the things I just searched on the web. But can't figure this out. Does somebody know what is wrong?
Thanks!
Joost
This worked for me a couple weeks ago:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node
Might have to use sudo if you get any access errors. Sometimes installing node through homebrew causes errors. So another alternative would be to uninstall it and download the node.js package and install it yourself without homebrew.

Uninstalling / Removing npm and node package on Mac

I am trying to remove the package download of npm and node that I installed to install them with Homebrew instead. However I am having great difficulty in doing this. How can I get the package version of node.js and npm totally removed from my Mac so I can install the Homebrew version?
Note: I have tried sudo npm rm --global node however I get the error sudo: npm: command not found
check the link below for uninstalling node/npm
How do I uninstall nodejs installed from pkg (Mac OS X)?
and the brew error is happening due to permmision issue.
Since brew basically don't allow to be executed with sudo so change the directory permission before brew command.
changing permission:
sudo chown -R $USER:admin /usr/local
brew link command:
brew link node
and then you can use npm or node commands.

Resources