Sharp: TypeError: Buffer.alloc is not a function, requires Node v4.5.0

Created on 15 Jun 2017  路  6Comments  路  Source: lovell/sharp

Got the following error:

[email protected] install /tmp/test/node_modules/sharp
node-gyp rebuild

/tmp/test/node_modules/sharp/node_modules/tar/lib/pack.js:32
const EOF = Buffer.alloc(1024)
^

TypeError: Buffer.alloc is not a function
at Object. (/tmp/test/node_modules/sharp/node_modules/tar/lib/pack.js:32:20)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/tmp/test/node_modules/sharp/node_modules/tar/lib/create.js:6:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
gyp: Call to 'GLOBAL_VIPS_VERSION="" node -e "require('./binding').use_global_vips()"' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error

seems like 0.18.x version is using a newer tar module which is not compatible with node 4.x

installing 0.17.x works fine.

enhancement

Most helpful comment

Added in commit ec617f2, thanks for the report!

All 6 comments

Hello, it looks like Buffer.alloc was added in Node 4.5.0 so I guess that's the new minimum. Happy for a PR to bump the minimum engine value to this.

Added in commit ec617f2, thanks for the report!

I'm still getting this error in node 6.10 on AWS builds.

```
/builds/project/node_modules/sharp/node_modules/tar/lib/pack.js:32
const EOF = Buffer.alloc(1024)
^

TypeError: Buffer.alloc is not a function
at Object. (/builds/project/node_modules/sharp/node_modules/tar/lib/pack.js:32:20)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/builds/project/node_modules/sharp/node_modules/tar/lib/create.js:6:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
gyp: Call to 'GLOBAL_VIPS_VERSION="" node -e "require('./binding').use_global_vips()"' returned exit status 1. while trying to load binding.gyp
ERROR: Job failed: exit code 1```

@stevensacks Buffer.alloc was added in v5.10.0 (and backported to Node v4.5.0).

The Changelog for Node v6.0.0 also mentions its availability.

The CI job for sharp v0.18.1 ran cleanly on Node v6.10.3.

Yeah. I'm definitely confused about this. Not sure why I'm getting this error on builds.

@stevensacks I was stuck on this for a while, just wanted to let you know what I did:

Use NVM to get latest version of Node (I went to latest - 8.1.2)
nvm use node
npm install

and now everything is fine 馃憤

Was this page helpful?
0 / 5 - 0 ratings