Installing a tar.gz on Linux - linux

I have downloaded Node.js from this link, which points to this link when clicking the button:
https://nodejs.org/dist/v4.1.2/node-v4.1.2-linux-x64.tar.gz
As advice from the Ubuntu community on installing the tar.gz, the following steps are followed.
$ ./configure
$ make
$ [sudo] make install
The problem is the current file I have downloaded does not contain ./configure.
So how do I install this? Should I extract this to the usr/ folder?
My OS is Debian 8 (Jessie).
Should I include the Java package from Oracle? Is it safe to extract these files to the /usr folder?

You can download this file from the browser or from the console. The latter is shown below (note: the specific Node.js version might be different for you):
Example :
wget http://nodejs.org/dist/v8.1.1/node-v8.1.1-linux-x64.tar.gz
sudo tar -C /usr/local --strip-components 1 -xzf node-v8.1.1-linux-x64.tar.gz
#tar options:
-x, --extract, --get
extract files from an archive
-f, --file ARCHIVE
use archive file or device ARCHIVE
-z, --gzip, --gunzip --ungzip`
You may find list of node version on http://nodejs.org/dist/
You should now have both Node.js and npm installed in “/usr/local/bin”. You can check this typing:
ls -l /usr/local/bin/node ls -l /usr/local/bin/npm
*An alternative way to install Node.js via the package manager:
Installing Node.js via package manager

Download the .tar.xz file form https://nodejs.org/en/ and then press Ctrl + Alt + T.
Then go to the destination that you downloaded your file to. For me it's my downloads folder. Then hit this command and Node.js will get installed on your system:
sudo tar -xf node-v16.0.0-linux-x64.tar.xz --directory=/usr/local --strip-components=1
This was the answer I had posted over two years ago, and here is what I recommand you right now, decompress the tarball, and keep it anywhere where your system knows ( tell it via updating $PATH ), its just a binary file, its not necessary to keep it in some specific location, you can keep it in your home directory and andd your bin folder to your bashrc or whatever shell you are using, its .rc file, and it will work just fine, at the end of the day, its just a pre-compiled binary file (inside node) nothing much.
Somebody in the comment section was saying npm, needs to be installed sepretly, this was in the early days of node back in 2012, when npm used to not ship with node, if you look inside bin folder npm binary is also there, so you dont need to install npm sepretly.

In case of installing from source code, you must download source code from https://nodejs.org/dist/v4.1.2/node-v4.1.2.tar.gz.
The file ending with .tar.gz is the compressed file like zip file, and you should extract the file before you can do another operation.
You can extract this file anywhere you need. In the terminal, change the location to your .tar.gz file:
$ cd /path/to/tar.gz/file
Then extract it using tar:
$ tar xvzf node-v4.1.2.tar.gz
Then change the location to the extracted directory
$ cd node-v4.1.2
After this, you can run .configure and 'make' it:
$ ./configure
$ make
$ [sudo] make install

Using the make utility is only necessary if you're compiling software. However, the tarballs provided by nodejs.org contain compiled binaries, not source code. Really you don't need to install it to use.
You can simply cd into the bin directory and run it via ./node. Though I'll say it's pretty useful to have it in your PATH. Where you put this directory doesn't really matter.
If you're installing it locally on your own machine, you can just untar it, tar xvfz node*tar.gz, to your home directory, add this to the file ~/.bashrc, and append the directory path your your PATH environment variable like so PATH=$PATH:/home/USERNAME/DIRECTORY/bin. Just change the path to the exact path to the bin folder in the directory you extracted.
You can also add these files to a directory that's already in your path, such as /usr/share or /usr/local by simple copying the files from the archive into these folders, as they share the same structure.

Run the following commands where your ta.xz file (no need for extraction) file is located in the terminal. NB: I used Kali Linux
sudo mkdir -p /usr/local/lib/nodejs
sudo tar -xJvf node-v14.4.0-linux-x64.tar.xz -C /usr/local/lib/nodejs
export PATH=/usr/local/lib/nodejs/node-node-v14.4.0-linux-x64/bin:$PATH
You can now check npm -v, node -v, and npx -v.

STEP 1:
Download your version of Node.js from the Node.js website or use the below command with your version:
wget http://nodejs.org/dist/v8.1.1/node-v8.1.1-linux-x64.tar.gz
You will get a Node.js file tar file after the above step.
STEP 2:
Just use the below command for installation
sudo tar -C /usr/local --strip-components 1 -xvf node-v8.1.1-linux-x64.tar.gz

I am mentioning version-specific installation of NVM and Node.js.
If you don't have brew installed, run this:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If you don't have wget installed, run this:
brew install wget
To install Node.js of a specific version, run these commands: Here, I'm installing NVM - v0.33.1 and Node.js of v0.12.6.
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
source ~/.bashrc
nvm install v0.12.6
command -v nvm //verify install

You can do some this:
# Using Ubuntu or Debian
curl -sL https://deb.nodesource.com/setup_[version].x | sudo -E bash -
sudo apt-get install -y nodejs
Where [version] must be replaced for your version of Node.js that you required install
For example, I required to install Node.js v.12
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

Download a suitable installation from
https://nodejs.org/en/download/
Incase of CentOS
Go to the downloaded file location
Execute the following
sudo tar -C /usr/local --strip-components 1 -xf "name of the tar.xz downloaded"
Check the installed version is correct
node --version

The given solution is correct, but it works for the source file and not the Linux distribution link used in the question above.
$ ./configure
$ make
$ [sudo] make install
The correct link is: https://nodejs.org/dist/v8.11.2/node-v8.11.2.tar.gz and we can use the above steps after downloading and extracting this file.

Download the latest version of Node.js from the official site, https://nodejs.org/en/
Steps to install:
Extract to any of the directories where you wish to install Node.js using a command or archive manager window
Open the terminal
Run '$sudo su'
Being superuser and open the profile file using 'nano ~/.profile'
At the end of the file, add:
# Node.js
export PATH=/path-to-bin.executable:$PATH
The path to bin application located within the bin folder of Node.js extracted folder is to be pasted in the above line
Save using Ctrl + O then come out by Ctrl + X
Refresh profile by the command '.~/.profile'
Come out of superuser by the 'exit' command
Again for normal users, use 'sudo'
'sudo nano ~/.profile'
Add the line at the end:
# Node.js
export PATH=/path-to-bin.executable:$PATH
Same as in step 5
Save and exit
Here the refresh command as above won't work, so restart the system to finish installation correctly
To get the version, issue 'node -v'

Related

Connot find executable after installation

I am trying to install KICS into AWS EC2 (Ubuntu). I am suing the one-line install script:
curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash
However when I run:
kics version
or
which kics
It seems like it cannot find the command. It forces me to reboot before being able to see it, however rebooting is not an option in my use-case.
As per the documentation of KICS (https://docs.kics.io/latest/getting-started/#one-liner_install_script):
Run the following command to download and install kics. It will detect your current OS and download the appropriate binary package, defaults installation to ./bin and the queries will be placed alongside the binary in ./bin/assets/queries:
curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash
If you want to place it somewhere else like /usr/local/bin:
sudo curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash -s -- -b /usr/local/bin
So by default, it will install in /home/<user>/bin folder if using the first command. This folder may not be in PATH environment variable because of which which command doesn't work.
So, you need to install using the second command in order to install in /usr/local/bin which should probably be there in PATH and after that which command will also work.

nodejs/bin/node does't exists when truing to install node.js on server

I have shaed hosting on siteground , basically my server runs PHP , but i also wanted to run node on my server , so i ssh'ed using putty and ran the following commands:
curl http:// nodejs.org/dist/latest/node-v8.11.3-linux-x64.tar.xz Then unzipped it.
mv node-v8.11.3-linux-x64/ nodejs.
mkdir ~/bin
cp nodejs/bin/node ~/bin
The last command throws an error
cp: connot stat nodejs/bin/node: no such file or directory exists
I was basically trying to follow the tutorial on HERE.
Follow this guide instead, it's from the actual node GitHub instead of a Medium article: How to install Node.js via binary archive on Linux?.
You are going to need 3 specific programs:
curl to download stuff
tar to deal with tar files
xz to deal with zip compression
Make sure all of those are installed using (and this assumes you're using Ubuntu or a distro that leverages apt):
sudo apt-get update && sudo apt-get install -y curl tar xz-utils
After that do something a little bit different from the tutorial
Download and save the archive:
curl -O https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz
Untar the archive:
tar xf node-v8.11.3-linux-x64.tar.xz
Make a nodejs directory to organize your versions:
mkdir /usr/local/lib/nodejs
Move the unarchived folder to your /usr/local/lib/nodejs folder:
mv node-v8.11.3-linux-x64 /usr/local/lib/nodejs/
Symlink node and npm into the /usr/bin/ folder:
ln -s /usr/local/lib/nodejs/node-v8.11.3-linux-x64/bin/node /usr/bin/node
ln -s /usr/local/lib/nodejs/node-v8.11.3-linux-x64/bin/npm /usr/bin/npm
Make sure everything is working:
node -v
npm -v

Install Node.js with downloaded binary on Ubuntu Desktop.. Where do the files go?

I've downloaded Node.js directly from https://nodejs.org/en/ onto my Ubuntu Desktop operating system. I can easily unpackage the node-vX.X.0-linux-x64.tar.xz file, and I can see node directories: bin, include, lib, share. I'm guessing my download folder, ~/Downloads/node-vX.X.0-linux-x64, is not going to be the final installation location.
My guess would be to copy all of the directory over to /usr/bin/node/node-vX.X.-linux-x64 but I'm not really sure.
Where do these files go? (I've tried the readme.md file in the download and the docs on that site. I would have thought something, somewhere on nodejs.org would have offered a bit of help...)
Is there a special installation step required here?
I wrote a tutorial to do exactly what you're asking: How to get Node 6.7.0 on Linux -
it's about Node 6.7.0 but you can just change the version number.
In short:
First get the files:
# If you have a 64-bit system then download binary package:
wget https://nodejs.org/dist/v6.7.0/node-v6.7.0-linux-x64.tar.gz
# If you have a 32-bit system then download a different version:
wget https://nodejs.org/dist/v6.7.0/node-v6.7.0-linux-x86.tar.gz
Extract:
# Extract what you downloaded:
tar xzvf node-v6.7.0-linux-x64.tar.gz
# Change the file ownership:
sudo chown -Rv root.root node-v6.7.0-linux-x64
Then install in ONE of the locations:
# Install files in /usr/local
sudo cp -Rvi node-v6.7.0-linux-x64/{bin,include,lib,share} /usr/local
# (change -Rvi to -Rvf if you want to overwrite existing files)
# Install files in /opt/node
sudo cp -Rvi node-v6.7.0-linux-x64 /opt/node
# Install files in /opt/node-6.7.0
sudo cp -Rvi node-v6.7.0-linux-x64 /opt/node-6.7.0
The difference between those 3 locations in the example is explained better in the article. The consequences are mostly related to PATH and installing multiple versions.
Finish the setup:
You need to make sure that directory where you have the node and npm binaries is in your PATH. See my tutorial for details on how to do that.
Beware of shebang lines:
The shebang line of npm in Node installed from binaries is different than when installed from sources. This is one of the reasons I recommand building from sources if you have time for that. The other reason is that installing from sources you can do make test to test the version of Node on your specific system, which you cannot do when installing from binaries or with nvm.

Node and NVM install broken on Ubuntu 14. Any ideas what I should do?

which node
returns
/usr/sbin/node
which nvm
returns nothing
nvm ls returns nothing
express no longer works
If I try curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
It says
nvm is already installed in /home/adam/.nvm, trying to update
=> HEAD is now at 7a423b7... v0.11.1
error: branch 'master' not found.
and it is true that .nvm is located there.
Any idea what I should do to either uninstall everything and reinstall it or fix my install?
The problem is that apt-get install nodejs installs node as "nodejs" on your path. Grunt, express, etc. all expect node to be node on your path. The reason for this is there was a package named node already in the Ubuntu apt repository before node.js came into existence, so node.js couldn't claim "node". The simplest solution is to do which nodejs then create a symlink targeting that file, name it node, and put that on your path (you can just put it in the same directory).
For you I recommend uninstalling everything first (apt-get remove).
I fixed this by deleting everything (purge Ubuntu packages and delete everything created by node and npm in /usr/*) and compiling the node package from their website.
I copied the commands from https://www.digitalocean.com/community/tutorials/how-to-install-an-upstream-version-of-node-js-on-ubuntu-12-04 instead of linking, in case the site goes offline:
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install
curl -L https://npmjs.org/install.sh | sh
node -v
The unofficial install scripts are buggy and it's about time they make an official repository or pre-compile some .deb files to make the installation easier. Hope this helps.

Installing NPM on AWS EC2

Working on Ec2 on AWS.
I have installed Node.js and it works fine.
But the problem arises when trying to install npm.
I am using the following command to install it:
sudo curl http://npmjs.org/install.sh | sh
But the install seems to freeze...
I get "fetching: http://registry.npmjs.org/npm/-/npm-1.0.106.tgz" at the prompt and it stays on like this.
Have any idea what is going on here?
sudo yum install nodejs npm --enablerepo=epel
Follow this AWS Tutorial that uses Node Version Manager.
Node Version Manager (NVM) lets you install multiple versions of Node.js and switch between them.
Here are the steps:
Install NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
Activate NVM
. ~/.nvm/nvm.sh
Install Node (choose version)
nvm install 15.0.0
Confirm Successful Installation
node -e "console.log('Running Node.js ' + process.version)"
To install NodeJS 6.x execute the following commands:
curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -
yum install nodejs --enablerepo=nodesource
Update
You can install NodeJS 7 and 8 in the same way. Just specify the version you need instead of 6 in the command above.
Update
To update to NodeJS 16 (or any other version) do the following:
rm -rf /etc/yum.repos.d/nodesource-el*
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
yum install nodejs --enablerepo=nodesource
Simplest way to install npm/nodejs on Amazon Linux 2 ec2 isntance:
First install epel repo using amazon-linux-extras command as below:
sudo amazon-linux-extras install epel
Now install npm and nodejs as below:
sudo yum install nodejs npm
you can verify the version of node and npm as below:
node -v
npm -v
PS. I've tested this on Amazon Linux 2 AMI (HVM) ec2 instance.
This guide worked perfectly: https://tecadmin.net/install-latest-nodejs-amazon-linux/
Make sure you have make
# sudo yum install -y gcc-c++ make
Install source
# curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
Install node
# sudo yum install -y nodejs
Note - you'll have to run sudo npm install to get the installs to work.
Firstly
sudo yum install make
You can run this to get zip of desired version of node
wget https://nodejs.org/dist/v8.10.0/node-v8.10.0.tar.gz
Then you can unzip it like this
tar -xvf node-v8.10.0.tar.gz
then go in to the extracted directory and install node like this
./configure && make && sudo make install
I found his tutorial that has been very usefull to me: The last chapter explains how to install node and npm compiling it.
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/#installNode
Get the http://npmjs.org/install.sh file on your system first and then execute it directly instead of piping with curl.
Use chmod +x install.sh to make it executable
Then run ./install.sh
I did it manually. Why mess with installers that break or don't put things where I want them? Such were the problems encountered while installing *node.js" on Amazon Web Services, that a manual install was the easy way to get the result I wanted.
I want a GLOBAL install of node and npm on AWS. By that I mean install should be put in a place like /usr/bin, so that all users have access. Surprisingly, AWS apparently doesn't give support to that idea. AWS encourages using nvm, node version manager, but that seems to always install in a user directory, and not a system level directory. After being frustrated when the "rpm" solutions (mentioned elsewhere) failed, I finally decided to just do the installation manually.
In a browser, go to nodejs.org download page:
https://nodejs.org/en/download/
Find a link that says:
All download options
Click through that; it goes to an index page with a URL like:
https://nodejs.org/dist/v14.16.1/
There I looked for the name that had "linux" and "x86" in the name.
I wrote this down, or select-and-copied, to get the correct spelling.
In my case it was:
node-v14.16.1-linux-x64.tar.gz
Putting the two parts together, I got the following URL:
https://nodejs.org/dist/v14.16.1/node-v14.16.1-linux-x64.tar.gz
So that's what is to be downloaded using curl.
I have a "temp" directory conveniently located in my home dir.
cd ~/temp
The download was accomplished with "curl". Note that the -o option was used to give the output file the name of my choosing. Of course, I chose to give it the same name as the web site file.
curl -o node-v14.16.1-linux-x64.tar.gz https://nodejs.org/dist/v14.16.1/node-v14.16.1-linux-x64.tar.gz
Untar the downloaded file.
tar xf node-v14.16.1-linux-x64.tar.gz
Conveniently, it creates its own directory. Go there.
cd node-v14.16.1-linux-x64 || exit 1;
Observe that the delivery consists of a relatively small number of files and directories (since node_modules is dealt with as a unit).
In my case, I had an old and bad implementation still installed, so the following commands were used to move aside any junk that might happen to be in the way. Some commands errored out because the old junk didn't exist. That's ok, error while moving to -OLD just means there is nothing to move; which is good.
Note: I put all these mv (move) commands into a script file, made it executable, and ran it as sudo. The alternative is to run each line individually as sudo.
mv /usr/bin/node /usr/bin/node-OLD
mv /usr/bin/npm /usr/bin/npm-OLD
mv /usr/bin/npx /usr/bin/npx-OLD
mv /usr/include/node /usr/include/node-OLD
mv /usr/lib/node_modules /usr/lib/node_modules-OLD
mv /usr/share/doc/node /usr/share/doc/node-OLD
mv /usr/share/man/man1/node.1 /usr/share/man/man1/node.1-OLD
mv /usr/share/systemtap/tapset/node.stp /usr/share/systemtap/tapset/node.stp-OLD
An here is the actual install. Remember, this is occurring in the untarred directory, in my case node-v14.16.1-linux-x64.
mv bin/node /usr/bin
mv bin/npm /usr/bin
mv bin/npx /usr/bin
mv include/node /usr/include
mv lib/node_modules /usr/lib
mv share/doc/node /usr/share/doc
mv share/man/man1/node.1 /usr/share/man/man1
mv share/systemtap/tapset/node.stp /usr/share/systemtap/tapset/
That's it, all finished.
Latest version 18 has dependency I think..
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
Finally I got solution by running by running following commands.
sudo apt-get remove nodejs
nvm install 16.15.1
v16.15.1 node version and npm v v16.15.1 is installed.
For same make sure nvm is installed in your machine.
This works for me:
sudo apt install npm
Edit as my answer wasn't pertinent anymore:
Try:
curl --silent --location https://rpm.nodesource.com/setup | bash -
yum -y install nodejs
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#enterprise-linux-and-fedora-core

Resources