|  | @@ -60,6 +60,13 @@ function get_npm_arch {
 | 
	
		
			
			| 60 | 60 |      fi
 | 
	
		
			
			| 61 | 61 |  }
 | 
	
		
			
			| 62 | 62 |  
 | 
	
		
			
			|  | 63 | +function nodejs_fix_cpu_detection {
 | 
	
		
			
			|  | 64 | +    if [ -f "$rootdir/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js" ]; then
 | 
	
		
			
			|  | 65 | +        # fix for failing cpu detection during image build with qemu, see https://github.com/npm/npm/issues/19265
 | 
	
		
			
			|  | 66 | +        sed -i "s|require('os').cpus.*|1|g" "$rootdir/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js"
 | 
	
		
			
			|  | 67 | +    fi
 | 
	
		
			
			|  | 68 | +}
 | 
	
		
			
			|  | 69 | +
 | 
	
		
			
			| 63 | 70 |  function mesh_install_nodejs {
 | 
	
		
			
			| 64 | 71 |      mesh_install_nodejs_prefix=
 | 
	
		
			
			| 65 | 72 |      if [ "$rootdir" ]; then
 | 
	
	
		
			
			|  | @@ -130,10 +137,9 @@ function mesh_install_nodejs {
 | 
	
		
			
			| 130 | 137 |      get_npm_arch
 | 
	
		
			
			| 131 | 138 |  
 | 
	
		
			
			| 132 | 139 |      $mesh_install_nodejs_prefix npm config set unsafe-perm true
 | 
	
		
			
			| 133 |  | -    if [ -f "$rootdir/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js" ]; then
 | 
	
		
			
			| 134 |  | -        # fix for failing cpu detection during image build with qemu, see https://github.com/npm/npm/issues/19265
 | 
	
		
			
			| 135 |  | -        sed -i "s|require('os').cpus().length|1|g" "$rootdir/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js"
 | 
	
		
			
			| 136 |  | -    fi
 | 
	
		
			
			|  | 140 | +    nodejs_fix_cpu_detection
 | 
	
		
			
			|  | 141 | +    # installing worker farm fixes the cpu detection bug
 | 
	
		
			
			|  | 142 | +    $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g worker-farm@1.5.2 --save
 | 
	
		
			
			| 137 | 143 |      $mesh_install_nodejs_prefix npm install --arch=$NPM_ARCH -g npm@${NPM_VERSION} --save
 | 
	
		
			
			| 138 | 144 |      if [ -f "$rootdir/usr/local/bin/npm" ]; then
 | 
	
		
			
			| 139 | 145 |          cp "$rootdir/usr/local/bin/npm" /usr/bin/npm
 |