Skip to main content

Install npm packages globally without root access

Image from nodejsblog.com


NPM packages can be installed locally under your home directory. With local installation you won't get error permissions while youre trying to install global npm packages.

Let's make your computer can run "npm install -g" without root access.
First, create npm packages directory

mkdir -p ~/.npm-packages

Add NPM_PACKAGES variable on your .bashrc file

echo NPM_PACKAGES="${HOME}/.npm-packages" >> ${HOME}/.bashrc

Add prefix to your npm configuration

echo prefix=${HOME}/.npm-packages >> ${HOME}/.npmrc

Install latest npm

curl -L https://www.npmjs.org/install.sh | sh

Add NODE_PATH variable to your .bashrc file

echo NODE_PATH=\"\$NPM_PACKAGES/lib/node_modules\:\$NODE_PATH\" >> ${HOME}/.bashrc

Update PATH variable

echo PATH=\"\$NPM_PACKAGES/bin\:\$PATH\" >> ${HOME}/.bashrc

Reload your environment variable

source ~/.bashrc

Now you can install global npm packages locally. Congrats....

Comments

Popular posts from this blog

How to use multiple PHP Version on Ubuntu 16.04

Ubuntu 16.04 came with PHP 7.0 packages. Sometimes we need to use older version of PHP. Bellow is the easiest way to get multiple versions of PHP on your Ubuntu PC's. First, you need to add my PPA repository. Open terminal and execute the following commands: sudo add-apt-repository ppa:agungwidodo/tphp Update your apt cache sudo apt update Finally, install tphp packages sudo apt install tphp After installation you will get application called PHP Switcher. Use these apps to switch your PHP version. This apps using PHP as CLI not as CGI, so you cant run multiple PHP version at same times. Plese leave a comment if you have any issues.

Realy Simple Point of Sale Program with QBASIC

Hi guys, This is maybe the simplest Point of Sale ever. This code i made to complete my home work even my studying at Nahdlatul Ulama University. Built on top of QBASIC programming language, the very old programming language, but i think this language is effective to learn basic programming. Because all programming language has same characteristics. So, guys, this is the code: ’’ —————————————————————————- ’’ PROGRAM KASIR SEDERHANA ’’ QBASIC ’’ —————————————————————————- ’’ Clear Screen CLS ’’ ’’ Deklarasi Variable ’’ DIM TRANSAKSI%(100) DIM PRODUK%(5) TOTALHARGA& = 0 TOTALITEM% = 0 ’’ Data Produk PRODUK%(1) = 1000 PRODUK%(2) = 1100 PRODUK%(3) = 1200 PRODUK%(4) = 1300 PRODUK%(5) = 1400 ’’ Main Menu 1 CLS PRINT “Menu:” PRINT “1. Produk” PRINT “2. Laporan” PRINT “3. Transaksi” PRINT “4. Keluar” INPUT “Pilih Menu:”, menu SELECT CASE menu CASE 1 GOTO 10 CASE 2 GOTO 20 CASE 3 GOTO 30 CASE 4 END END SELECT ’’ Data produk 10 CLS PRINT ...