Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: grunt.util._(...).chain(...).pluck is not a function Use --force to continue. #90

Open
konstantinj opened this issue May 2, 2016 · 6 comments

Comments

@konstantinj
Copy link

with grunt 1.0.1 and grunt-contrib-clean 1.0.0.

@hilnius
Copy link

hilnius commented Jul 25, 2016

I have the same error

@chocolateboy
Copy link

chocolateboy commented Aug 22, 2016

Packages:

  • grunt v0.4.5
  • grunt-cli v1.2.0
  • grunt-contrib-clean v0.6.0
  • grunt-legacy-util 0.2.0
  • node v6.3.1
  • npm 3.10.5

Error:

TypeError: grunt.util._(...).chain(...).pluck is not a function
    at Object.<anonymous> (node_modules/grunt/lib/grunt/task.js:260:55)
    at Object.<anonymous> (node_modules/grunt-contrib-clean/tasks/clean.js:53:9)
    at Object.<anonymous> (node_modules/grunt/lib/grunt/task.js:265:15)
    at Object.thisTask.fn (node_modules/grunt/lib/grunt/task.js:82:16)
    at Object.<anonymous> (node_modules/grunt/lib/util/task.js:301:30)
    at Task.runTaskFn (node_modules/grunt/lib/util/task.js:251:24)
    at Task.<anonymous> (node_modules/grunt/lib/util/task.js:300:12)
    at node_modules/grunt/lib/util/task.js:227:11
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

node_modules/grunt/lib/grunt/task.js:260:

257    Object.defineProperty(this, 'filesSrc', {                                    
258      enumerable: true,                                                          
259      get: function() {                                                          
260        return grunt.util._(this.files).chain().pluck('src').flatten().uniq().value();
261      }.bind(this)                                                               
262    });

Cause:

lodash v4.0.0 removed pluck in favour of map (which can now take a string). On my system, node_modules/grunt-legacy-util/node_modules didn't exist (not sure why), but node_modules/lodash (v4.x) did. In the absence of a nested lodash, the top-level lodash was being used (cf. peer dependencies).

Solution:

mv node_modules old.node_modules
npm install

If the error still persists, update npm, do another fresh npm install, and ensure the following conditions are met:

  • If the filesSrc getter uses pluck, node_modules/grunt-legacy-util/node_modules/lodash must be < v4.0.0.
  • If the filesSrc getter uses map, node_modules/grunt-legacy-util/node_modules/lodash must be >= v4.0.0.

@chocolateboy
Copy link

chocolateboy commented Jan 1, 2017

Just spotted another example of this where there's a discrepancy between a package in node_modules and the tarball for that module on NPM. Specifically, the package.json for a nested dependency (glob-stream) didn't match the index.js for that package. This was occurring with npm v2.15.1 on node v0.10.48.

Reinstalling node_modules didn't help, but clearing the NPM cache and reinstalling did:

$ npm cache clean
$ rm -rf node_modules
$ npm install

@chocolateboy
Copy link

It might have something to do with this: npm/npm#4042

@sachinhasaranda
Copy link

Thanks Bro

@Ali7285
Copy link

Ali7285 commented May 16, 2022

_.chain(...).pluck is not a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants