node.jscpusystem-information

Node JS - Systeminformation, cpuTemperature function does not return temperature


I am working on a project where I want to access and display the temperature of my CPU. I found a tutorial where I via the "systeminformation" package can gain access to mutliple CPU stats. But when I use the cpuTemperature function it does not return the temperature, instead it returns "-1" and empty list and "-1".

si.cpuTemperature(function(data) {
  console.log('CPU-Temperature:');
  console.log(data);
});

=> { main: -1, cores: [], max: -1 }

Am I doing something wrong or is my CPU not supporting this type of event?

Tutorial I have used: https://github.com/sebhildebrandt/systeminformation


Solution

  • I presume you are trying that on windows. Accoording to docs you need to run wmic with admin privileges, if you don't get any data. For OSX and Linux you also need some extra packages installed like osx-temperature-sensor Node module for OSX, and the sensors package (lm-sensors for Debian based) Linux machines. You can try to run node from an Administrator terminal to check out the privilege issue on Windows.