Lodash publishes several builds from the same source. Pick the smallest one that covers the methods you use.
Requirements
- Node.js 4.0.0 or later, if you run Lodash outside a browser.
- Any environment that can load a UMD module (CommonJS, AMD, or a global browser script).
Install with npm
bash
npm install lodashImport the full build, which includes every method documented in this reference:
js
var _ = require('lodash');Choose a smaller build
The core build covers a focused subset of methods for basic array, collection, and object manipulation. It excludes methods such as debounce, cloneDeep, and most Lang and String methods.
js
var _ = require('lodash/core');Load in a browser
html
<script src="lodash.js"></script>This exposes the _ global. Lodash is also available from CDN mirrors such as jsDelivr; see the CDN copies list on the project's download page.
Verify the install
Run a method that only exists in the full build to confirm you loaded what you expect:
js
var _ = require('lodash');
console.log(_.VERSION);
// => '4.18.1'
console.log(_.chunk(['a', 'b', 'c', 'd'], 2));
// => [['a', 'b'], ['c', 'd']]If both lines print without a
TypeError, the build you loaded includes _.chunk and you're ready to continue with the quickstart.Next steps
- Follow the quickstart for a complete first task.
- Browse the API reference for every supported method.
- Read Core concepts before relying on a method to mutate or not mutate its input.