How to Install Node.js without sudo access but with npm 1.3.10 installed?
Solution 1:
In order to install Node.js and npm locally without having to use sudo open the terminal and type:
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
wget -c http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install
wget -c https://www.npmjs.org/install.sh | sh
The curl package is not installed in Ubuntu by default. If you don't have curl installed on your system, replace all instances of curl
in the install.sh file with wget -c
and save the changes to the install.sh file before running it.
This will install node-v9.2.0 which is a later version of Node.js than the file you already downloaded.
Solution 2:
I workout this way - in 2 steps.
Step 1: Download and extract nodejs binaries
# create a directory where you want to install node js
mkdir ~/nodejs-latest
# download and extract nodejs binaries into the created directory
cd ~/nodejs-latest
wget -c http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
Step 2: Set PATH and source
# append the following lines to the ~/.bashrc file
export NODE_HOME=~/nodejs-latest
export PATH=$PATH:$NODE_HOME/bin
# refresh environment variables
source ~/.bashrc
You can then verify the nodejs installation with node --version
and npm --version
.