|  | @@ -175,17 +175,22 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 175 | 175 |  
 | 
	
		
			
			| 176 | 176 |      # update from the old debian nodejs version
 | 
	
		
			
			| 177 | 177 |      $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
 | 
	
		
			
			| 178 |  | -    #$mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
 | 
	
		
			
			| 179 |  | -    #nodejs_fix_cpu_detection
 | 
	
		
			
			| 180 |  | -    #cp "$rootdir/root/npm" "$rootdir/usr/bin/npm"
 | 
	
		
			
			| 181 |  | -    #cp "$rootdir/root/npm" "$rootdir/usr/local/bin/npm"
 | 
	
		
			
			| 182 |  | -
 | 
	
		
			
			| 183 |  | -    # deliberate second install of npm
 | 
	
		
			
			| 184 |  | -    #$mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
 | 
	
		
			
			| 185 |  | -    #if [ -f "$rootdir/usr/local/bin/npm" ]; then
 | 
	
		
			
			| 186 |  | -    #    cp "$rootdir/usr/local/bin/npm" "$rootdir/usr/bin/npm"
 | 
	
		
			
			| 187 |  | -    #fi
 | 
	
		
			
			| 188 |  | -    #cp "$rootdir/usr/bin/npm" "$rootdir/root/npm"
 | 
	
		
			
			|  | 178 | +    if [ ! "$rootdir" ]; then
 | 
	
		
			
			|  | 179 | +        # Don't do this if we're building an image,
 | 
	
		
			
			|  | 180 | +        # because cpu detection faults occur.
 | 
	
		
			
			|  | 181 | +        # This condition may no longer be needed in future once the bug is fixed
 | 
	
		
			
			|  | 182 | +        $mesh_install_nodejs_prefix n --arch $N_ARCH ${NODEJS_VERSION}
 | 
	
		
			
			|  | 183 | +        nodejs_fix_cpu_detection
 | 
	
		
			
			|  | 184 | +        cp "$rootdir/root/npm" "$rootdir/usr/bin/npm"
 | 
	
		
			
			|  | 185 | +        cp "$rootdir/root/npm" "$rootdir/usr/local/bin/npm"
 | 
	
		
			
			|  | 186 | +
 | 
	
		
			
			|  | 187 | +        # deliberate second install of npm
 | 
	
		
			
			|  | 188 | +        $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
 | 
	
		
			
			|  | 189 | +        if [ -f "$rootdir/usr/local/bin/npm" ]; then
 | 
	
		
			
			|  | 190 | +            cp "$rootdir/usr/local/bin/npm" "$rootdir/usr/bin/npm"
 | 
	
		
			
			|  | 191 | +        fi
 | 
	
		
			
			|  | 192 | +        cp "$rootdir/usr/bin/npm" "$rootdir/root/npm"
 | 
	
		
			
			|  | 193 | +    fi
 | 
	
		
			
			| 189 | 194 |      if [ -f "$rootdir/usr/bin/node" ]; then
 | 
	
		
			
			| 190 | 195 |          cp "$rootdir/usr/bin/node" "$rootdir/usr/local/bin/node"
 | 
	
		
			
			| 191 | 196 |      fi
 |