Create a global directory for node modules installed with npm
This commit is contained in:
parent
8094acfdf1
commit
88b9907f6f
|
@ -173,6 +173,8 @@ EOF
|
||||||
fi
|
fi
|
||||||
rm "$rootdir/usr/bin/test_nodejs_install"
|
rm "$rootdir/usr/bin/test_nodejs_install"
|
||||||
NODE_UPGRADE=
|
NODE_UPGRADE=
|
||||||
|
|
||||||
|
nodejs_setup_global_modules
|
||||||
}
|
}
|
||||||
|
|
||||||
function nodejs_upgrade {
|
function nodejs_upgrade {
|
||||||
|
@ -201,6 +203,21 @@ function nodejs_upgrade {
|
||||||
npm update -g
|
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 {
|
function remove_nodejs {
|
||||||
if [ ! "$1" ]; then
|
if [ ! "$1" ]; then
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue