# TypeError: \_.pluck is not a function

**URL:** <https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [November 11, 2024, 12:05pm UTC](https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085 "2024-11-11T12:05:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrobbo76](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mrobbo76](https://community.postman.com/u/mrobbo76)\
**Post date:** [November 11, 2024, 12:05pm UTC](https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085/1 "2024-11-11T12:05:47Z")

</div>

Hello,

In our collection, we have a script that uses :

\_.pluck

When we run the endpoint, we see the following error in console :

Using “\_” is deprecated. Use “require(‘lodash’)” instead.

In our scripts, we have added :

const \_ = require(‘lodash’);

However, the following error is returned :

TypeError: \_.pluck is not a function

Any ideas on how to resolve? Thanks.

---

<div class="post-metadata">

**Author:** ![mrobbo76](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mrobbo76](https://community.postman.com/u/mrobbo76)\
**Post date:** [November 11, 2024, 12:36pm UTC](https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085/2 "2024-11-11T12:36:09Z")

</div>

Looks like I’ve gotten further following : [What Happened to Lodash \_.pluck? - GeeksforGeeks](https://www.geeksforgeeks.org/what-happened-to-lodash-pluck/?ref=oin_asr3)

(changing \_.pluck to \_.map).

Thanks

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 11, 2024, 2:52pm UTC](https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085/3 "2024-11-11T14:52:43Z")

</div>

Hey @mrobbo76 👋

Glad to see you found the answer here. 🏆

Postman was running 2 separate versions of Lodash in the sandbox.

With the `_.*` entry point it would have been using the the [older 3.10.1 version](https://lodash.com/docs/3.10.1#pluck) which `pluck` was part of but with our recent changes we are using the newer version. This [doesn’t include that function](https://lodash.com/docs/4.17.15#pluck) and show the error.

As you have found out already, the `.map()` function can be used as a replacement in most cases:

```auto
const _ = require('lodash');

let users = [
  { 'user': 'barney' },
  { 'user': 'fred' }
];
 
let userList = _.map(users, 'user');

console.log(userList);

```

---

<div class="post-metadata">

**Author:** ![mrobbo76](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mrobbo76](https://community.postman.com/u/mrobbo76)\
**Post date:** [November 12, 2024, 9:10am UTC](https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085/4 "2024-11-12T09:10:26Z")

</div>

Amazing. Thanks for getting back to me, Danny. Keep up the great work 👍

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 9:11am UTC](https://community.postman.com/t/typeerror-pluck-is-not-a-function/71085/5 "2024-12-12T09:11:19Z")

</div>

Closed on December 12, 2024, 9:11am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
