{"id":18512,"library":"lodash.first","title":"lodash.first","description":"The lodash.first package provides the modern build of lodash's `_.first` function as a standalone npm module, version 3.0.0. This package is part of lodash's modularized approach, allowing developers to import only the specific utility they need, reducing bundle size compared to using the full lodash library. Note that since lodash v4, `_.first` has been deprecated in favor of `_.head`, which offers identical functionality. The modularized packages like lodash.first are frozen at lodash v3.0.0 and are not updated with new releases; they remain in maintenance mode.","status":"maintenance","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript","lodash","lodash-modularized","stdlib","util"],"install":[{"cmd":"npm install lodash.first","lang":"bash","label":"npm"},{"cmd":"yarn add lodash.first","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash.first","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Internal dependency needed by lodash.first for the baseFirst implementation","package":"lodash._basefirst","optional":false},{"reason":"Internal helper used to validate iteratee calls","package":"lodash._isiterateecall","optional":false},{"reason":"Internal function to get native methods safely","package":"lodash._getnative","optional":false}],"imports":[{"note":"This package only provides a CommonJS require API; ESM import is unsupported. For ES modules, use lodash-es or the full lodash with tree-shaking.","wrong":"import first from 'lodash.first'","symbol":"first","correct":"var first = require('lodash.first')"},{"note":"lodash/first path was not part of lodash v3; use _.first or the standalone package.","wrong":"var first = require('lodash/first')","symbol":"_.first","correct":"var _ = require('lodash'); var first = _.first"},{"note":"In lodash v4, _.first is deprecated in favor of _.head. Use head if you want current API.","wrong":"var first = require('lodash.first')","symbol":"head","correct":"var head = require('lodash.head')"}],"quickstart":{"code":"var first = require('lodash.first');\n\n// Get first element of an array\nconsole.log(first([1, 2, 3])); // 1\nconsole.log(first([])); // undefined\n\n// Works with strings too\nconsole.log(first('hello')); // 'h'\n\n// Works on array-like objects\nvar args = function() { return arguments; };\nconsole.log(first(args('a', 'b'))); // 'a'","lang":"javascript","description":"Demonstrates basic usage of lodash.first to get the first element of arrays, strings, and array-like objects."},"warnings":[{"fix":"Switch to require('lodash.head') or use the full lodash v4+.","message":"lodash.first is frozen at v3.0.0 and will not receive updates. Use lodash.head instead for current lodash API.","severity":"gotcha","affected_versions":"<=3.0.0"},{"fix":"Use _.head instead.","message":"_.first deprecated in lodash v4 in favor of _.head.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Ensure input is array-like before calling first.","message":"In lodash v3, _.first expects an array-like object. Passing a non-array-like (e.g., number) may throw or return undefined.","severity":"breaking","affected_versions":">=3.0.0 <4.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install lodash.first' in your project directory.","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'lodash.first'"},{"fix":"Use 'var first = require('lodash.first');' and ensure package is installed.","cause":"Incorrect import style (e.g., default import) or missing require.","error":"TypeError: first is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}