diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs index a557cfff..3068b2bc 100755 --- a/src/freedombone-utils-nodejs +++ b/src/freedombone-utils-nodejs @@ -173,6 +173,8 @@ EOF fi rm "$rootdir/usr/bin/test_nodejs_install" NODE_UPGRADE= + + nodejs_setup_global_modules } function nodejs_upgrade { @@ -201,6 +203,21 @@ function nodejs_upgrade { npm update -g } +function nodejs_setup_global_modules { + if [ ! -d /root/.npm-global ]; then + mkdir /root/.npm-global + fi + npm config set prefix '/root/.npm-global' + export PATH=/root/.npm-global/bin:$PATH + if ! grep -q "PATH=/root/.npm-global/bin" /root/.bashrc; then + echo "PATH=/root/.npm-global/bin:\$PATH" >> /root/.bashrc + fi + if ! grep -q "NPM_CONFIG_PREFIX=" /root/.bashrc; then + echo "export NPM_CONFIG_PREFIX=/root/.npm-global" >> /root/.bashrc + fi + export NPM_CONFIG_PREFIX=/root/.npm-global +} + function remove_nodejs { if [ ! "$1" ]; then return