{"id":14212,"library":"useragent","title":"User Agent Parser for Node.js","description":"The `useragent` package, currently at version 2.3.0, is an abandoned Node.js library designed for parsing user agent strings. It was developed to provide high accuracy by leveraging hand-tuned regular expressions derived from Browserscope's research, aiming to correctly identify browser names and versions where generic parsers might fail. The library differentiated itself through a benchmark-driven approach, claiming superior performance with a pre-compiled regular expression library and deferred parsing for OS and device information. It also offered an optional feature to fetch live, updated parsing rules from remote servers, requiring additional `yamlparser` and `request` dependencies. However, the package has not seen updates since its last publish 8 years ago, indicating it is no longer actively maintained and its user agent data is significantly out of date, making it unsuitable for modern applications.","status":"abandoned","version":"2.3.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/3rd-Eden/useragent","tags":["javascript","agent","browser","browserscope","os","parse","parser","ua","ua-parse"],"install":[{"cmd":"npm install useragent","lang":"bash","label":"npm"},{"cmd":"yarn add useragent","lang":"bash","label":"yarn"},{"cmd":"pnpm add useragent","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required if `useragent(true)` is called to fetch and compile live user agent definitions.","package":"yamlparser","optional":true},{"reason":"Required if `useragent(true)` is called to fetch live user agent definitions from a remote server.","package":"request","optional":true}],"imports":[{"note":"This package is CommonJS-only. Direct ESM import will fail without a compatibility layer.","wrong":"import useragent from 'useragent';","symbol":"useragent","correct":"const useragent = require('useragent');"},{"note":"The primary parsing function is a method of the default export, not a named export itself.","wrong":"const { parse } = require('useragent');","symbol":"useragent.parse","correct":"const agent = useragent.parse(userAgentString);"},{"note":"The `Agent` instance is returned by `useragent.parse` and is not directly exported for import.","wrong":"import { Agent } from 'useragent';","symbol":"Agent","correct":"const agent = useragent.parse(userAgentString); console.log(agent.toAgent());"}],"quickstart":{"code":"const useragent = require('useragent');\n\n// Simulate a request header user agent string\nconst serverUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36';\n\n// Simulate an optional client-side JavaScript user agent string (e.g., from Chrome Frame detection)\nconst clientUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Chrome-Frame/90.0.4430.212';\n\n// Parse only the server user agent\nconst agent1 = useragent.parse(serverUserAgent);\nconsole.log('Agent 1 (server only):', agent1.toAgent());\nconsole.log('OS 1:', agent1.os.toAgent());\n\n// Parse both server and client user agents\nconst agent2 = useragent.parse(serverUserAgent, clientUserAgent);\nconsole.log('Agent 2 (server + client):', agent2.toAgent());\nconsole.log('OS 2:', agent2.os.toAgent());\n\n// Attempt to update the database (requires 'yamlparser' and 'request' to be installed)\n// useragent(true); // Uncomment with caution, as dependencies are old and may have security issues\n\n/* Example Output:\nAgent 1 (server only): Chrome 123.0.0\nOS 1: Mac OS X 10.15.7\nAgent 2 (server + client): Chrome Frame 90.0.4430\nOS 2: Windows 10\n*/","lang":"javascript","description":"Demonstrates basic usage of `useragent.parse()` with server-side and optional client-side user agent strings, and how to access parsed properties."},"warnings":[{"fix":"Migrate to a actively maintained and up-to-date user agent parsing library (e.g., 'ua-parser-js', 'platform').","message":"The `useragent` package is effectively abandoned, with its last update 8 years ago. This means its internal database of user agent parsing rules is severely outdated and will incorrectly parse or fail to recognize modern browsers, operating systems, and devices.","severity":"breaking","affected_versions":">=2.3.0"},{"fix":"Ensure your project is configured for CommonJS or use a bundler that transpiles CommonJS modules for ESM environments. Alternatively, choose a modern library that supports ESM natively.","message":"This package is CommonJS-only (`require`). Attempting to use `import` syntax in an ESM module without a bundler or transpiler will result in a runtime error.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Avoid using the `useragent(true)` feature. If you must use this library, rely solely on its bundled, albeit outdated, definitions. Preferably, migrate to a modern, actively maintained user agent parser.","message":"The optional feature to fetch live user agent definitions by calling `useragent(true)` relies on the `yamlparser` and `request` packages. Both of these are very old and unmaintained, with `request` being officially deprecated and having known security vulnerabilities. Using this feature introduces significant security risks and potential compatibility issues with newer Node.js versions.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Benchmark against current alternatives if performance is critical for modern user agents; however, the primary issue remains the outdated parsing database.","message":"The accuracy claims are based on benchmarks from 8+ years ago against contemporary libraries. Modern alternatives have likely surpassed its performance and accuracy, especially concerning up-to-date user agent strings.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.3.0':12 '8':117 'abandon':15 'accuraci':30 'activ':125 'addit':101 'agent':2,22,130,144 'ago':119 'aim':43 'also':86 'applic':142 'approach':65 'benchmark':63 'benchmark-driven':62 'browser':47,145 'browserscop':40,146 'claim':66 'compil':73 'correct':45 'current':9 'data':131 'date':136 'defer':78 'depend':105 'deriv':38 'design':18 'develop':26 'devic':83 'differenti':58 'driven':64 'express':37,75 'fail':55 'featur':90 'fetch':92 'generic':52 'hand':34 'hand-tun':33 'high':29 'howev':106 'identifi':46 'indic':120 'inform':84 'javascript':143 'last':115 'leverag':32 'librari':17,57,76 'live':93 'longer':124 'maintain':126 'make':137 'might':54 'modern':141 'name':48 'node.js':5,16 'offer':87 'option':89 'os':81,147 'packag':8,108 'pars':20,79,95,148,153 'parser':3,53,149 'perform':68 'pre':72 'pre-compil':71 'provid':28 'publish':116 'regular':36,74 'remot':98 'request':104 'requir':100 'research':42 'rule':96 'seen':111 'server':99 'signific':133 'sinc':113 'string':23 'superior':67 'tune':35 'ua':150,152 'ua-pars':151 'unsuit':139 'updat':94,112 'user':1,21,129 'userag':7 'version':11,50 'yamlpars':102 'year':118","created_at":"2026-04-20T01:58:31.272105+00:00","updated_at":"2026-04-20T01:58:31.272105+00:00","problems":[{"fix":"Ensure your file is a CommonJS module (e.g., by using `.js` extension with `\"type\": \"commonjs\"` in `package.json` or by not setting `\"type\": \"module\"`). If using ESM, you might need to use `import * as useragent from 'useragent';` or a build tool to handle CJS imports.","cause":"Attempting to `require('useragent')` in an ECMAScript Module (ESM) file without proper transpilation or bundling.","error":"TypeError: require is not a function"},{"fix":"To use the live update feature, you must explicitly install `yamlparser` and `request` via `npm install yamlparser request --save`. However, this is strongly discouraged due to the age and known vulnerabilities of these dependencies.","cause":"The `useragent(true)` function was called to fetch and compile live user agent definitions, but the optional `yamlparser` dependency was not installed.","error":"Error: Cannot find module 'yamlparser'"},{"fix":"This issue cannot be fixed within this library. You must switch to a different, actively maintained user agent parsing library that receives regular updates.","cause":"The package's user agent definition database is 8 years old and does not contain rules for recent browsers, operating systems, or device patterns.","error":"Incorrectly parsed or unrecognized user agent string for a modern browser/OS."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.1.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/3rd-Eden/useragent","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/useragent","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}