grunt-s3 icon indicating copy to clipboard operation
grunt-s3 copied to clipboard

has no method 'init'

Open whyvez opened this issue 11 years ago • 5 comments

Trying to use with Yeoman 1.0.

  1. Installed grunt-s3 via npm .
  2. Added s3 config section as per documentation.
  3. Registered npm task like grunt.loadNpmTasks('grunt-s3');.

When I run grunt s3 I get:

Loading "s3.js" tasks...ERROR

TypeError: Object #<Object> has no method 'init'

Any suggestions?

whyvez avatar May 16 '13 16:05 whyvez

What happens when you run with grunt s3 -v --stack?

NickHeiner avatar May 30 '13 21:05 NickHeiner

I followed your steps but couldn't reproduce. I think @NickHeiner's suggestion is a good start.

pifantastic avatar Jun 04 '13 05:06 pifantastic

Hi, I got the same error, here's the relevant log portion:

Registering "grunt-s3" local Npm module tasks.
Reading /Users/paulodeon/Code/project/node_modules/grunt-s3/package.json...OK
Parsing /Users/paulodeon/Code/project/node_modules/grunt-s3/package.json...OK
Loading "s3.js" tasks...ERROR
>> TypeError: Object #<Object> has no method 'init'
>>     at Object.exportFn (/Users/paulodeon/Code/project/node_modules/grunt-s3/tasks/s3.js:27:11)
>>     at loadTask (/Users/paulodeon/Code/project/node_modules/grunt/lib/grunt/task.js:312:10)
>>     at /Users/paulodeon/Code/project/node_modules/grunt/lib/grunt/task.js:348:7
>>     at Array.forEach (native)
>>     at loadTasks (/Users/paulodeon/Code/project/node_modules/grunt/lib/grunt/task.js:347:11)
>>     at Task.task.loadNpmTasks (/Users/paulodeon/Code/project/node_modules/grunt/lib/grunt/task.js:395:5)
>>     at Object.module.exports (/Users/paulodeon/Code/project/Gruntfile.js:347:11)
>>     at loadTask (/Users/paulodeon/Code/project/node_modules/grunt/lib/grunt/task.js:312:10)
>>     at Task.task.init (/Users/paulodeon/Code/project/node_modules/grunt/lib/grunt/task.js:424:5)
>>     at Object.grunt.tasks (/Users/paulodeon/Code/project/node_modules/grunt/lib/grunt.js:113:8)
Loading "Gruntfile.js" tasks...OK
+ build, default, server, test

paulodeon avatar Jun 13 '13 21:06 paulodeon

@pifantastic @whyvez the issue is likely double including grunt-s3

yeoman puts this line in:

  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

and then if you add:

  grunt.loadNpmTasks('grunt-s3');

You'll be loading it twice. Since https://github.com/pifantastic/grunt-s3/blob/master/tasks/s3.js#L27 overwrites the s3 variable it is not idempotent and will throw the error.

nickblt avatar Jul 02 '13 21:07 nickblt

Am also seeing this error when used with AngularJS. Removing the line:

grunt.loadNpmTasks('grunt-s3');

sorted the problem. Thanks @nletourneau

bensquire avatar Nov 05 '13 14:11 bensquire