{"id":11505,"library":"os-utils","title":"OS Utils","description":"The `os-utils` package is a Node.js library offering fundamental operating system utility functions. It enables developers to retrieve basic system metrics such as CPU usage (calculated per second, not as an average), total and free memory, platform identification, and system/process uptime. The package's latest version, 0.0.14, was released on October 30, 2012, signifying that its development has ceased and it is no longer actively maintained. Its release cadence was effectively non-existent after this initial publication. Compared to contemporary system monitoring libraries like `node-os-utils` or `systeminformation`, `os-utils` provides a very limited, callback-based API, lacks modern features such as TypeScript support, sophisticated error handling, or intelligent caching mechanisms, making it unsuitable for modern Node.js applications or environments requiring robust system insights.","status":"abandoned","version":"0.0.14","language":"javascript","source_language":"en","source_url":"git://github.com/oscmejia/os-utils","tags":["javascript","os","operating system","server","memory","cpu","monitor","stats","harddrive"],"install":[{"cmd":"npm install os-utils","lang":"bash","label":"npm"},{"cmd":"yarn add os-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add os-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a CommonJS module from 2012. ESM `import` syntax will result in an `ERR_REQUIRE_ESM` error in most modern Node.js environments unless specific compatibility flags or bundler configurations are used. Always use `require()`.","wrong":"import os from 'os-utils';","symbol":"module object","correct":"const os = require('os-utils');"},{"note":"Functions like `cpuUsage` are properties of the default exported module object. They are accessed via `os.cpuUsage()`, not as named exports.","wrong":"import { cpuUsage } from 'os-utils';","symbol":"cpuUsage","correct":"const os = require('os-utils');\nos.cpuUsage(function(v) { /* ... */ });"},{"note":"Similar to `cpuUsage`, this is a method on the default module object. Attempts to destructure or directly import it will fail.","wrong":"import { freememPercentage } from 'os-utils';","symbol":"freememPercentage","correct":"const os = require('os-utils');\nos.freememPercentage();"}],"quickstart":{"code":"const os = require('os-utils');\n\n// Get CPU usage for the next second\nos.cpuUsage(function(v) {\n  console.log('CPU Usage (%): ' + v);\n});\n\n// Get free CPU for the next second\nos.cpuFree(function(v) {\n  console.log('CPU Free (%): ' + v);\n});\n\n// Get platform name\nconsole.log('Platform:', os.platform());\n\n// Get number of CPUs\nconsole.log('CPU Count:', os.cpuCount());\n\n// Get current free memory in MB\nconsole.log('Free Memory (MB):', os.freemem());\n\n// Get total memory in MB\nconsole.log('Total Memory (MB):', os.totalmem());\n\n// Get free memory percentage\nconsole.log('Free Memory Percentage (%):', os.freememPercentage());","lang":"javascript","description":"This quickstart demonstrates how to initialize `os-utils` and retrieve various system metrics such as CPU usage, memory information, and system details using its callback-based API."},"warnings":[{"fix":"Migrate to actively maintained alternatives like `node-os-utils` (https://www.npmjs.com/package/node-os-utils) or `systeminformation` (https://www.npmjs.com/package/systeminformation) for reliable system monitoring.","message":"The `os-utils` package is completely unmaintained, with its last update over a decade ago (version 0.0.14 published in October 2012). It is highly likely to have compatibility issues with modern Node.js versions and environments.","severity":"breaking","affected_versions":">=0.0.14"},{"fix":"Consider wrapping `os-utils` functions in Promises for better integration, or, preferably, switch to a modern library that provides native Promise support.","message":"The package uses a callback-based API, which is an outdated pattern in modern asynchronous JavaScript. Integrating it into Promise-based or async/await codebases requires manual promisification or wrapper functions.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Be aware of this distinction when interpreting CPU metrics. For more accurate average CPU usage, consider using the native `os.cpus()` module with custom calculation logic or a more robust monitoring library.","message":"The `cpuUsage` and `cpuFree` functions calculate CPU usage for 'the next second' and are not true averages like those provided by Node.js's native `os` module or other monitoring tools. This can lead to misleading or inconsistent metrics.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Avoid using `os-utils` in production environments. Prioritize secure, actively maintained packages for any OS-level interactions to mitigate potential security risks.","message":"Being an unmaintained package, `os-utils` may contain unpatched security vulnerabilities. Directly interacting with operating system APIs through outdated code poses a significant supply chain risk.","severity":"breaking","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your file is a CommonJS module (e.g., ends with `.cjs` or `package.json` specifies `'type': 'commonjs'`) or refactor your project to use an ESM-compatible system monitoring library. You *cannot* `import` this package directly as it's pure CommonJS.","cause":"Attempting to use `require('os-utils')` within an ECMAScript Module (ESM) file or project configured as 'type': 'module' in `package.json`.","error":"ERR_REQUIRE_ESM: require() of ES Module ... not supported. Instead change the require of ... to a dynamic import()"},{"fix":"Always import `os-utils` using `const os = require('os-utils');` and access its methods as `os.methodName()`. Verify `npm install os-utils` completed successfully.","cause":"Incorrectly trying to destructure the module or using an import syntax that results in `os` not being the module object, or the `os-utils` package wasn't installed correctly.","error":"TypeError: os.cpuUsage is not a function"}],"ecosystem":"npm"}