{"id":10400,"library":"lodash","title":"lodash","description":"lodash is a JavaScript utility library providing consistent, cross-environment, performance-optimized, and modular utilities for common programming tasks. It simplifies working with arrays, objects, numbers, strings, and functions, offering a wide range of helpers for iteration, manipulation, and type checking. The current stable version is 4.18.1, with frequent updates for bug fixes and security patches, typically released as minor or patch versions.","status":"active","version":"4.18.1","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript","modules","stdlib","util"],"install":[{"cmd":"npm install lodash","lang":"bash","label":"npm"},{"cmd":"yarn add lodash","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The 'lodash' package supports both CommonJS and ESM imports. For optimal tree-shaking in modern bundlers, consider using 'lodash-es'.","wrong":"const _ = require('lodash');","symbol":"_","correct":"import _ from 'lodash';"}],"quickstart":{"code":"import _ from 'lodash';\n\nconst users = [\n  { 'user': 'barney', 'age': 36, 'active': true },\n  { 'user': 'fred',   'age': 40, 'active': false }\n];\n\nconst activeUsers = _.filter(users, function(o) { return o.active; });\n\nconsole.log(activeUsers);\n// Expected output: [ { user: 'barney', age: 36, active: true } ]","lang":"typescript","description":"Demonstrates importing the full lodash library and using the `_.filter` method to process an array of objects."},"warnings":[{"fix":"Consult the [v4.0.0 Changelog](https://github.com/lodash/lodash/wiki/Changelog#v400) for migration details.","message":"lodash v4.0.0 introduced significant back-compatible breaking changes to align with semantic versioning practices.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Consult the [v3.0.0 release notes](https://github.com/lodash/lodash/tree/3.0.0) for migration details.","message":"lodash v3.0.0 included several back-compatible breaking changes as part of a major cleanup and refactoring.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade to `lodash@4.18.0` or higher to address security vulnerability GHSA-f23m-r3pf-42rh.","message":"A prototype pollution vulnerability via `_.unset` and `_.omit` path traversal was fixed.","severity":"gotcha","affected_versions":"<4.18.0"},{"fix":"Upgrade to `lodash@4.18.1` or higher to resolve this `ReferenceError`.","message":"A `ReferenceError` could occur when using `_.template` or `_.fromPairs` from modular builds due to internal dependency issues.","severity":"gotcha","affected_versions":"4.18.0"},{"fix":"Install `n_` (`npm i -g n_`) for Node.js < 6 REPL support, or use Node.js v6 or higher.","message":"Lodash functionality in the Node.js REPL may be inconsistent or require a polyfill for Node.js versions prior to 6.","severity":"gotcha","affected_versions":"Node.js < 6"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Upgrade `lodash` to version `4.18.1` or higher.","cause":"Internal dependency mapping issue in `_.template` or `_.fromPairs` functions when imported individually or from modular builds in versions prior to 4.18.1.","error":"ReferenceError: <variable name> is not defined"},{"fix":"Refactor `const _ = require('lodash');` to `import _ from 'lodash';` for ESM compatibility.","cause":"Attempting to use CommonJS `require` syntax within an ES Module (ESM) file context.","error":"TypeError: require is not a function"},{"fix":"Refactor `import _ from 'lodash';` to `const _ = require('lodash');` for CJS compatibility, or configure your project to use ES Modules (e.g., by setting `\"type\": \"module\"` in `package.json`).","cause":"Attempting to use ES Module `import` syntax within a CommonJS (CJS) file context or a project not configured for ESM.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm"}