Handle image install of global node modules directory

This commit is contained in:
Bob Mottram 2018-03-30 14:15:04 +01:00
parent 88b9907f6f
commit 68f94f498e
1 changed files with 11 additions and 9 deletions

View File

@ -204,18 +204,20 @@ function nodejs_upgrade {
}
function nodejs_setup_global_modules {
if [ ! -d /root/.npm-global ]; then
mkdir /root/.npm-global
if [ ! -d "$rootdir/root/.npm-global" ]; then
mkdir "$rootdir/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
$mesh_install_nodejs_prefix npm config set prefix '/root/.npm-global'
if ! grep -q "PATH=/root/.npm-global/bin" "$rootdir/root/.bashrc"; then
echo "PATH=/root/.npm-global/bin:\$PATH" >> "$rootdir/root/.bashrc"
fi
if ! grep -q "NPM_CONFIG_PREFIX=" /root/.bashrc; then
echo "export NPM_CONFIG_PREFIX=/root/.npm-global" >> /root/.bashrc
if ! grep -q "NPM_CONFIG_PREFIX=" "$rootdir/root/.bashrc"; then
echo "export NPM_CONFIG_PREFIX=/root/.npm-global" >> "$rootdir/root/.bashrc"
fi
if [ ! "$rootdir" ]; then
export PATH=/root/.npm-global/bin:$PATH
export NPM_CONFIG_PREFIX=/root/.npm-global
fi
export NPM_CONFIG_PREFIX=/root/.npm-global
}
function remove_nodejs {