kevva / to-ico

Convert PNG to ICO in memory
MIT License
137 stars 19 forks source link

Module build failed: TypeError: Buffer.alloc is not a function #11

Closed dzoba closed 7 years ago

dzoba commented 7 years ago

There is an issue with the new release that is killing my build. It is with this line:

https://github.com/kevva/to-ico/blob/master/index.js#L15

This is the relevant part of the error:

 70% 1406/1406 build modulesModuleBuildError: Module build failed: TypeError: Buffer.alloc is not a function
    at n (/Users/christopherdzoba/v/brawndo/node_modules/to-ico/index.js:15:21)
    at /Users/christopherdzoba/v/brawndo/node_modules/to-ico/index.js:90:18

I am using node 5.2.0

dzoba commented 7 years ago

Looks like Buffer.alloc was added in 5.10.0 https://nodejs.org/api/buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding

Ideally the package could work for many versions, but if not then this should be updated: https://github.com/kevva/to-ico/blob/master/package.json#L13

mynnx commented 7 years ago

Can confirm. Module is used by https://github.com/jantimon/favicons-webpack-plugin; my webpack-dev-server build hangs and my webpack build fails with that error as well.

Upgrading to Node 6 solved the problem, but not everyone can do so.

SamVerschueren commented 7 years ago

Buffer.alloc was backported to Node 4 as well. Make sure you have the latest LTS version.

kevva commented 7 years ago

Yup, should be available in Node.js 4 (since 4.5.0). See https://nodejs.org/dist/latest-v4.x/docs/api/buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding.

dzoba commented 7 years ago

Thank you @SamVerschueren and @kevva - you guys are totally right. Unfortunately we won't be able to update node versions for a couple weeks, so, in the mean time I've forked the relevant repos and reverted the change until we can update node. I'm leaving this note here to save anyone else some work who may be in the same boat.

https://github.com/dzoba/favicons-webpack-plugin -> https://github.com/dzoba/favicons -> https://github.com/dzoba/to-ico

And in package.json

    "favicons-webpack-plugin": "git://github.com/dzoba/favicons-webpack-plugin.git",