|  | @@ -72,6 +72,7 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 72 | 72 |      $mesh_install_nodejs_prefix wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O /root/node.gpg.key
 | 
	
		
			
			| 73 | 73 |      if [ ! -f "$rootdir/root/node.gpg.key" ]; then
 | 
	
		
			
			| 74 | 74 |          echo $'Unable to obtain gpg key for nodejs repo'
 | 
	
		
			
			|  | 75 | +        NODE_UPGRADE=
 | 
	
		
			
			| 75 | 76 |          exit 6389252
 | 
	
		
			
			| 76 | 77 |      fi
 | 
	
		
			
			| 77 | 78 |      $mesh_install_nodejs_prefix apt-key add /root/node.gpg.key
 | 
	
	
		
			
			|  | @@ -82,9 +83,12 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 82 | 83 |      $mesh_install_nodejs_prefix apt-get update
 | 
	
		
			
			| 83 | 84 |      $mesh_install_nodejs_prefix apt-get -yq remove --purge nodejs
 | 
	
		
			
			| 84 | 85 |  
 | 
	
		
			
			| 85 |  | -    if [ -d "$rootdir/usr/local/lib/node_modules" ]; then
 | 
	
		
			
			| 86 |  | -        rm -rf "$rootdir/usr/local/lib/node_modules"
 | 
	
		
			
			|  | 86 | +    if [ ! $NODE_UPGRADE ]; then
 | 
	
		
			
			|  | 87 | +        if [ -d "$rootdir/usr/local/lib/node_modules" ]; then
 | 
	
		
			
			|  | 88 | +            rm -rf "$rootdir/usr/local/lib/node_modules"
 | 
	
		
			
			|  | 89 | +        fi
 | 
	
		
			
			| 87 | 90 |      fi
 | 
	
		
			
			|  | 91 | +
 | 
	
		
			
			| 88 | 92 |      if [ -f "$rootdir/usr/local/bin/node" ]; then
 | 
	
		
			
			| 89 | 93 |          rm "$rootdir/usr/local/bin/node"
 | 
	
		
			
			| 90 | 94 |      fi
 | 
	
	
		
			
			|  | @@ -111,6 +115,7 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 111 | 115 |          if [ ! -f "${rootdir}/usr/local/bin/node" ]; then
 | 
	
		
			
			| 112 | 116 |              if [ ! -f "${rootdir}/usr/bin/nodejs" ]; then
 | 
	
		
			
			| 113 | 117 |                  echo $'nodejs was not installed'
 | 
	
		
			
			|  | 118 | +                NODE_UPGRADE=
 | 
	
		
			
			| 114 | 119 |                  exit 63962
 | 
	
		
			
			| 115 | 120 |              fi
 | 
	
		
			
			| 116 | 121 |          fi
 | 
	
	
		
			
			|  | @@ -118,6 +123,7 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 118 | 123 |  
 | 
	
		
			
			| 119 | 124 |      if [ ! -f "$rootdir/usr/bin/node" ]; then
 | 
	
		
			
			| 120 | 125 |          echo $'/usr/bin/node not found'
 | 
	
		
			
			|  | 126 | +        NODE_UPGRADE=
 | 
	
		
			
			| 121 | 127 |          exit 7235728
 | 
	
		
			
			| 122 | 128 |      fi
 | 
	
		
			
			| 123 | 129 |  
 | 
	
	
		
			
			|  | @@ -162,9 +168,11 @@ EOF
 | 
	
		
			
			| 162 | 168 |      chmod +x "$rootdir/usr/bin/test_nodejs_install"
 | 
	
		
			
			| 163 | 169 |      if ! $mesh_install_nodejs_prefix /usr/bin/test_nodejs_install; then
 | 
	
		
			
			| 164 | 170 |          echo $"nodejs version numbers did not match. Architecture is $NPM_ARCH."
 | 
	
		
			
			|  | 171 | +        NODE_UPGRADE=
 | 
	
		
			
			| 165 | 172 |          exit 76835282
 | 
	
		
			
			| 166 | 173 |      fi
 | 
	
		
			
			| 167 | 174 |      rm "$rootdir/usr/bin/test_nodejs_install"
 | 
	
		
			
			|  | 175 | +    NODE_UPGRADE=
 | 
	
		
			
			| 168 | 176 |  }
 | 
	
		
			
			| 169 | 177 |  
 | 
	
		
			
			| 170 | 178 |  function nodejs_upgrade {
 | 
	
	
		
			
			|  | @@ -187,6 +195,7 @@ function nodejs_upgrade {
 | 
	
		
			
			| 187 | 195 |      fi
 | 
	
		
			
			| 188 | 196 |      read_config_param ARCHITECTURE
 | 
	
		
			
			| 189 | 197 |      get_npm_arch
 | 
	
		
			
			|  | 198 | +    NODE_UPGRADE=1
 | 
	
		
			
			| 190 | 199 |      rootdir=
 | 
	
		
			
			| 191 | 200 |      mesh_install_nodejs
 | 
	
		
			
			| 192 | 201 |  }
 |