Install Node.js with downloaded binary on Ubuntu Desktop.. Where do the files go?
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 & NPM linux binary installation
I have added "/home/varun/node/lib/node_modules/npm/bin/npm" to my PATH variable. (Before node location). Also, have made the following changes for it to work.
12c12
< node "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
---
> node "$basedir/npm-cli.js" "$
How to install node.tar.xz file in linux
Steps to download and install node in ubuntu
Step 1: Download latest or recommended node .tar.xz file from https://nodejs.org/en/
or you can download node version 14.15.5 (.tar.xz file) directly from here ->
https://nodejs.org/dist/v14.15.5/node-v14.15.5-linux-x64.tar.xz
Step 2: Go to the directory in which (.tar.xz file) is downloaded.
In my case --> /Download directory
Step 3: Update System Repositories
sudo apt update
Step 4: Install the package xz-utils
sudo apt install xz-utils
Step 5: To Extract the .tar.xz file
sudo tar -xvf name_of_file
In my case --> sudo tar -xvf node-v14.15.5-linux-x64.tar.xz
Step 6: sudo cp -r directory_name/{bin,include,lib,share} /usr/
In my case --> sudo cp -r node-v14.15.5-linux-x64/{bin,include,lib,share} /usr/
Step 7: Update the Path export PATH=/usr/node_directory_name/bin:$PATH
In my case --> export PATH=/usr/node-v14.15.5-linux-x64/bin:$PATH
Step 8: Check the node version
node --version
Result In my case -> v14.15.5
Uninstall nodejs installed from binary distribution files
I got the solution from the links given below
http://hungred.com/how-to/completely-removing-nodejs-npm/
How to install node binary distribution files on Linux
I did the following steps and it works fine
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/lib/node_modules/
sudo rm -rf /usr/local/include/node/
sudo rm -rf /usr/local/share/man/man1/node.1
cd /home/userName
ls -ld .?* (to display hidden files)
# delete files/folders related with node
sudo rm -f .node_repl_history
sudo rm -rf .npm
To Re-install new version follow the below steps
1.Download new version from Node official website.In my case my downloaded file is node-v6.9.4-linux-x64.tar.xz
2.Move the file into /usr/local directory using the command
sudo mv Downloads/node-v6.9.4-linux-x64.tar.xz /usr/local
3.Use the below command to extract into appropriate directories in /usr/local
sudo tar --strip-components 1 -xf node-v6.9.4-linux-x64.tar.xz
-xf is to unzip .tar.xz for tar.gz use -xzf
4.verify installation
node --version
Install NPM into home directory with distribution nodejs package (Ubuntu)
NPM will install local packages into your projects already, but I still like to keep the system away from my operating system's files. Here's how I suggest compartmentalizing Nodejs packages:
Install Nodejs and NPM via the chris-lea PPA. Then I set up a package root in my homedir to hold the Node "global" packages:
$ NPM_PACKAGES="$HOME/.npm-packages"
$ mkdir -p "$NPM_PACKAGES"
Set NPM to use this directory for its global package installs:
$ echo "prefix = $NPM_PACKAGES" >> ~/.npmrc
Configure your PATH and MANPATH to see commands in your $NPM_PACKAGES prefix by adding the following to your .zshrc/.bashrc:
# NPM packages in homedir
NPM_PACKAGES="$HOME/.npm-packages"
# Tell our environment about user-installed node tools
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
# Tell Node about these packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
Now when you do an npm install -g
, NPM will install the libraries into ~/.npm-packages/lib/node_modules
, and link executable tools into ~/.npm-packages/bin
, which is in your PATH
.
Just use npm install -g
as you would normally:
[justjake@marathon:~] $ npm install -g coffee-script
... (npm downloads stuff) ...
/home/justjake/.npm-packages/bin/coffee -> /home/justjake/.npm-packages/lib/node_modules/coffee-script/bin/coffee
/home/justjake/.npm-packages/bin/cake -> /home/justjake/.npm-packages/lib/node_modules/coffee-script/bin/cake
coffee-script@1.3.3 /home/justjake/.npm-packages/lib/node_modules/coffee-script
[justjake@marathon:~] $ which coffee
/home/justjake/.npm-packages/bin/coffee
Distribute a binary executable with a nodejs module when publishing to npmjs.com
supply a
bin
field in yourpackage.json
which is a map of command name to local file name. On install, npm will symlink that file intoprefix/bin
for global installs, or./node_modules/.bin/
for local installs.
For example, if you have this in the package.json
, and installed your package globally, the command npmputty
will be available in the PATH.
"bin": {
"npmputty": "./bin/putty.exe"
},
If you prefer to not release this executable in the package, it is possible to implement a postinstall
script to download it from somewhere like github.com.
{
"scripts" : {
"postinstall" : "scripts/download_from_github.js"
}
}
Related Topics
Platform Independent Resource Management
Hosting Two Website Under One Web App - Azure Services
What Is the Meaning of Each Line of the Assembly Output of a C Hello World
When Setting Ifs to Split on Newlines, Why Is It Necessary to Include a Backspace
Docker Bash Prompt Does Not Display Color Output
Linux Configure/Make, --Prefix
Using Rsync Filter to Include/Exclude Files
Does The Bios Copy The 512-Byte Bootloader to 0X7C00
Why Can Back-Quotes and $() for Command Substitution Result in Different Output
Size() VS Ls -La VS Du -H Which One Is Correct Size
Bash Shell Script Variable Assignment
Iterating Over Each Line of Ls -L Output
How to Start Docker Service in Ubuntu 16.04
How to Set Limit on Directory Size in Linux