Skip to main content

One post tagged with "no root"

View All Tags

· One min read
Hreniuc Cristian-Alexandru

Install nodejs in a specific path:

echo 'export PATH=$HOME/programs/bin:$PATH' >> ~/.bashrc
# the `programs` dir should exist, the `bin` will be
# created if it doesn't exist, when you will be running `./configure`
source ~/.bashrc
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=$HOME/programs # your prefix
make install# --j8
# The `make install` step takes a lot, you should do it on multiple threads using --j option

Install npm on specific path:

wget https://registry.npmjs.org/npm/-/npm-5.8.0.tgz # specify what version you want 
tar xzf npm-5.8.0.tgz
cd package/
node bin/npm-cli.js install -gf --prefix=~/programs/ ../npm-5.8.0.tgz
# use the prefix where node was installed

Test them both:

node -v
#
npm -v