Giter Site home page Giter Site logo

node-zopfli's Introduction

node-zopfli

NPM version Linux Build Status Windows Build Status Coverage Status Dependency Status devDependency Status Stories in Ready

Node.js bindings for Zopfli compressing library. Compress gzip files 5% better compared to gzip.

It is considerably slower than gzip (~100x) so you may want to use it only for static content and cached resources.

Prerequisites for building

Usage

Install

npm install node-zopfli

or if you want zopfli binary globally

npm install -g node-zopfli

Binary (from command line)

To gzip a file

zopfli file.txt

To compress a png file

zopflipng file.png out.png

Usage examples

Stream (async):

var zopfli = require('node-zopfli');
fs.createReadStream('file.js')
  .pipe(zopfli.createGzip(options))
  .pipe(fs.createWriteStream('file.js.gz'));

Instead of zopfli.createGzip, you can also use

new Zopfli('gzip', options);

Buffer (async):

var zopfli = require('node-zopfli');
var input = new Buffer('I want to be compressed');
zopfli.deflate(input, options, function(err, deflated) {});
zopfli.zlib(input, options, function(err, zlibed) {});
zopfli.gzip(input, options, function(err, gziped) {});

Buffer (sync):

var zopfli = require('node-zopfli');
var input = new Buffer('I want to be compressed');
var deflated = zopfli.deflateSync(input, options);
var zlibed = zopfli.zlibSync(input, options);
var gziped = zopfli.gzipSync(input, options);

API

compress(input, format, [options, callback])

input is the input buffer

format can be one of deflate, zlib and gzip

callback, if present, gets two arguments (err, buffer) where err is an error object, if any, and buffer is the resultant compressed data.

If no callback is provided, it returns an A+ Promise.

aliases

deflate, zlib and gzip methods are aliases on compress without format argument.

Options

Here are the options with defaults values you can pass to zopfli:

{
  verbose: false,
  verbose_more: false,
  numiterations: 15,
  blocksplitting: true,
  blocksplittinglast: false,
  blocksplittingmax: 15
}
numiterations

Maximum amount of times to rerun forward and backward pass to optimize LZ77 compression cost. Good values: 10, 15 for small files, 5 for files over several MB in size or it will be too slow.

blocksplitting

If true, splits the data in multiple deflate blocks with optimal choice for the block boundaries. Block splitting gives better compression.

blocksplittinglast

If true, chooses the optimal block split points only after doing the iterative LZ77 compression. If false, chooses the block split points first, then does iterative LZ77 on each individual block. Depending on the file, either first or last gives the best compression.

blocksplittingmax

Maximum amount of blocks to split into (0 for unlimited, but this can give extreme results that hurt compression on some files).

Build from sources

git clone https://github.com/pierreinglebert/node-zopfli --recursive
cd node-zopfli
npm install

Tests

mocha is used for tests, you can run them with:

npm test

node-zopfli's People

Contributors

duralog avatar kturney avatar lydell avatar mariusbuescher avatar mattrobenolt avatar nstepien avatar pierreinglebert avatar vmeurisse avatar xhmikosr avatar xmikus01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-zopfli's Issues

installation failed

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v6.11.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure

you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-zopfli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-zopfli
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-zopfli
npm ERR! There is likely additional logging output above.

NOTE: There are no log file

Can't install on CentOS 7?

Hi,
I tried to install node-zopfli with both npm and node-gyp. The first complains during build, the second finds an undefined variable (or maybe I did something wrong). Can you please take a look at build logs? I'm on node-0.12.7.

installing with npm

$ npm install node-zopfli                                                                                       
|                                                                                                                               
> [email protected] install /home/bkheyfets/node_modules/node-zopfli                                                            
> node-pre-gyp install --fallback-to-build                                                                                      

make: Entering directory `/home/bkheyfets/node_modules/node-zopfli/build'                                                       
  CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o                                                                    
In file included from ../node_modules/nan/nan_new.h:189:0,
                 from ../node_modules/nan/nan.h:200,
                 from ../src/zopfli-binding.h:5,
                 from ../src/zopfli-binding.cc:3:
../node_modules/nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::Function>::return_t Nan::imp::Factory<v8::Function>::New(Nan::FunctionCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan_implementation_12_inl.h:94:67: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
                                                                   ^
../node_modules/nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’:
../node_modules/nan/nan_implementation_12_inl.h:122:69: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
                                                                     ^
In file included from ../src/zopfli-binding.h:5:0,
                 from ../src/zopfli-binding.cc:3:
../node_modules/nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
../node_modules/nan/nan.h:1908:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:1913:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h: In function ‘bool Nan::SetAccessor(v8::Local<v8::Object>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)’:
../node_modules/nan/nan.h:1951:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:1960:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h: In function ‘void Nan::SetNamedPropertyHandler(v8::Local<v8::ObjectTemplate>, Nan::PropertyGetterCallback, Nan::PropertySetterCallback, Nan::PropertyQueryCallback, Nan::PropertyDeleterCallback, Nan::PropertyEnumeratorCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:1998:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:2003:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h:2009:57: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(query)));
                                                         ^
../node_modules/nan/nan.h:2015:59: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(deleter)));
                                                           ^
../node_modules/nan/nan.h:2021:62: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(enumerator)));
                                                              ^
../node_modules/nan/nan.h: In function ‘void Nan::SetIndexedPropertyHandler(v8::Local<v8::ObjectTemplate>, Nan::IndexGetterCallback, Nan::IndexSetterCallback, Nan::IndexQueryCallback, Nan::IndexDeleterCallback, Nan::IndexEnumeratorCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2068:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:2073:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h:2079:57: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(query)));
                                                         ^
../node_modules/nan/nan.h:2085:59: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(deleter)));
                                                           ^
../node_modules/nan/nan.h:2091:62: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(enumerator)));
                                                              ^
../node_modules/nan/nan.h: In function ‘void Nan::SetCallHandler(v8::Local<v8::FunctionTemplate>, Nan::FunctionCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2124:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(callback)));
                                                          ^
../node_modules/nan/nan.h: In function ‘void Nan::SetCallAsFunctionHandler(v8::Local<v8::ObjectTemplate>, Nan::FunctionCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2146:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(callback)));
                                                          ^
../src/zopfli-binding.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE nodezopfli::CompressBinding::Sync(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/zopfli-binding.cc:173:20: warning: ‘format’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     &out, &outsize);
                    ^
../src/zopfli-binding.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE nodezopfli::CompressBinding::Async(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/zopfli-binding.cc:105:78: warning: ‘format’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   : Nan::AsyncWorker(callback), format(format), zopfli_options(zopfli_options) {
                                                                              ^
../src/zopfli-binding.cc:150:16: note: ‘format’ was declared here
   ZopfliFormat format;
                ^
  CXX(target) Release/obj.target/zopfli/src/png/zopflipng.o
In file included from ../node_modules/nan/nan_new.h:189:0,
                 from ../node_modules/nan/nan.h:200,
                 from ../src/png/zopflipng.cc:3:
../node_modules/nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::Function>::return_t Nan::imp::Factory<v8::Function>::New(Nan::FunctionCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan_implementation_12_inl.h:94:67: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
                                                                   ^
../node_modules/nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::FunctionTemplate>::return_t Nan::imp::Factory<v8::FunctionTemplate>::New(Nan::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>)’:
../node_modules/nan/nan_implementation_12_inl.h:122:69: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , v8::External::New(isolate, reinterpret_cast<void *>(callback)));
                                                                     ^
In file included from ../src/png/zopflipng.cc:3:0:
../node_modules/nan/nan.h: In function ‘void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)’:
../node_modules/nan/nan.h:1908:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:1913:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h: In function ‘bool Nan::SetAccessor(v8::Local<v8::Object>, v8::Local<v8::String>, Nan::GetterCallback, Nan::SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute)’:
../node_modules/nan/nan.h:1951:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:1960:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h: In function ‘void Nan::SetNamedPropertyHandler(v8::Local<v8::ObjectTemplate>, Nan::PropertyGetterCallback, Nan::PropertySetterCallback, Nan::PropertyQueryCallback, Nan::PropertyDeleterCallback, Nan::PropertyEnumeratorCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:1998:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:2003:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h:2009:57: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(query)));
                                                         ^
../node_modules/nan/nan.h:2015:59: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(deleter)));
                                                           ^
../node_modules/nan/nan.h:2021:62: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(enumerator)));
                                                              ^
../node_modules/nan/nan.h: In function ‘void Nan::SetIndexedPropertyHandler(v8::Local<v8::ObjectTemplate>, Nan::IndexGetterCallback, Nan::IndexSetterCallback, Nan::IndexQueryCallback, Nan::IndexDeleterCallback, Nan::IndexEnumeratorCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2068:56: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(getter)));
                                                        ^
../node_modules/nan/nan.h:2073:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(setter)));
                                                          ^
../node_modules/nan/nan.h:2079:57: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(query)));
                                                         ^
../node_modules/nan/nan.h:2085:59: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(deleter)));
                                                           ^
../node_modules/nan/nan.h:2091:62: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
       , New<v8::External>(reinterpret_cast<void *>(enumerator)));
                                                              ^
../node_modules/nan/nan.h: In function ‘void Nan::SetCallHandler(v8::Local<v8::FunctionTemplate>, Nan::FunctionCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2124:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(callback)));
                                                          ^
../node_modules/nan/nan.h: In function ‘void Nan::SetCallAsFunctionHandler(v8::Local<v8::ObjectTemplate>, Nan::FunctionCallback, v8::Local<v8::Value>)’:
../node_modules/nan/nan.h:2146:58: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Wpedantic]
     , New<v8::External>(reinterpret_cast<void *>(callback)));
                                                          ^
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/blocksplitter.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/cache.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/deflate.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/gzip_container.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/hash.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/katajainen.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/lz77.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/squeeze.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/tree.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/util.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/zlib_container.o
  CC(target) Release/obj.target/zopfli/zopfli/src/zopfli/zopfli_lib.o
  CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/zopflipng_lib.o
  CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/lodepng/lodepng.o
  CXX(target) Release/obj.target/zopfli/zopfli/src/zopflipng/lodepng/lodepng_util.o
  SOLINK_MODULE(target) Release/obj.target/zopfli.node
  COPY Release/zopfli.node
  COPY /home/bkheyfets/node_modules/node-zopfli/lib/binding/node-v14-linux-x64/zopfli.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory `/home/bkheyfets/node_modules/node-zopfli/build'
[email protected] node_modules/node-zopfli
├── [email protected]
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
└── [email protected]

installing with node-gyp

$ cd node-zopfli-1.4.0
$ node-gyp configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/bkheyfets/zop/node-zopfli-1.4.0/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/bkheyfets/.node-gyp/0.12.7/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/bkheyfets/.node-gyp/0.12.7',
gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/bkheyfets/zop/node-zopfli-1.4.0',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.10.0-327.4.4.el7.x86_64
gyp ERR! command "node" "/usr/bin/node-gyp" "configure"
gyp ERR! cwd /home/bkheyfets/zop/node-zopfli-1.4.0
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok

Error with 1.3.2

module.js:338
    throw err;
          ^
Error: Cannot find module '../build/Release/zopfli'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\xmr\AppData\Roaming\npm\node_modules\node-zopfli\bin\zopflipng:7:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

Does not work on RHEL6?

node-zopfli does not appear to work on RHEL6. It seems to have a dependency on glibc 2.14, and the supported version in RHEL6 is 2.12.

This is impacting Simon Fraser University's (github/sfu) ability to deploy our Learning Managment System, instructure/canvas-lms, since it now has a dependency on node-zopfli (via ryankshaw/brandable_css).

DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/canvas-lms/Rakefile:11)
--> Starting: 'Making sure node_modules are up to date'
--> Finished: 'Making sure node_modules are up to date' in 4.800319236
--> Starting: 'compile css (including custom brands)'
module.js:522
  var nodePath = process.env['NODE_PATH'];
                        ^
Error: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /tmp/canvas-lms/node_modules/brandable_css/node_modules/node-zopfli/lib/binding/node-v14-linux-x64/zopfli.node)
    at Error (native)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/tmp/canvas-lms/node_modules/brandable_css/node_modules/node-zopfli/lib/zopfli.js:7:14)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/tmp/canvas-lms/node_modules/brandable_css/lib/handleGzip.js:11:37)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
--> Finished: 'compile css (including custom brands)' in 1.171742863

Failed at the [email protected] install script

Hello everybody.
I tried to install dependencies at my project, but it fails on [email protected] install script. Could you take a look at the errors?

34516 verbose stack Error: [email protected] install: `node-pre-gyp install --fallback-to-build`
34516 verbose stack Exit status 1
34516 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
34516 verbose stack     at EventEmitter.emit (events.js:182:13)
34516 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
34516 verbose stack     at ChildProcess.emit (events.js:182:13)
34516 verbose stack     at maybeClose (internal/child_process.js:962:16)
34516 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
34517 verbose pkgid [email protected]
34518 verbose cwd [local path]
34519 verbose Darwin 18.0.0
34520 verbose argv "/usr/local/Cellar/node/11.0.0/bin/node" "/usr/local/bin/npm" "install" "--no-package-lock"
34521 verbose node v11.0.0
34522 verbose npm  v6.4.1
34523 error code ELIFECYCLE
34524 error errno 1
34525 error [email protected] install: `node-pre-gyp install --fallback-to-build`
34525 error Exit status 1
34526 error Failed at the [email protected] install script.

missing node-v44-linux-arm binding error

Looks like I'm missing a node-v44-linux-arm binding, node-v43-linux-arm seems to be there and the module did install without an error. Any ideas?

$ node -v
v2.5.0
$ npm -v
2.13.2
$ npm ls node-zopfli
[email protected] /srv/droppy/app
└── [email protected]
$ node /srv/droppy/app/droppy.js start
module.js:338
    throw err;
          ^
Error: Cannot find module '/srv/droppy/app/node_modules/node-zopfli/lib/binding/node-v44-linux-arm/zopfli.node'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/srv/droppy/app/node_modules/node-zopfli/lib/zopfli.js:7:14)
    at Module._compile (module.js:430:26)
    at Object.Module._extensions..js (module.js:448:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
$ ls /srv/droppy/app/node_modules/node-zopfli/lib/binding/
node-v43-linux-arm  node-v44-darwin-x64

Build failure on Ununtu 14.10

After my latest software update node-zopfli is failing to build. I can't seem to track down the source of the problem. The regular command line package for zopfli is fine (not sure if they are connected).

Wondering if these lines are of any help:

gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:340:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.13.0-48-generic

One thing that strikes me is the build script is running node-gyp from my system-wide /usr/lib/ directory... Which shouldn't be used any more. Or at least I thought I over rode that a while ago 😐. I use nvm to manage all my node/io versions. Shouldn't it be calling gyp from there?

Something like:

/home/me/.nvm/versions/node/v0.12.1/lib/node_modules/npm/node_modules/node-gyp

Not sure if that helps. Let me know if posting the full npm-debug.log file would help.

Installation fails on Linux

❯ node --version
v7.9.0
❯ npm --version
4.2.0
❯ python --version
Python 2.7.13
❯ gcc --version
gcc (GCC) 6.3.1 20170306
❯ npm install node-zopfli

> [email protected] install /tmp/node-zopfli-test/node_modules/node-zopfli
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v51-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v51 ABI) (falling back to source compile with node-gyp) 
Traceback (most recent call last):
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 130, in Load
    params['parallel'], params['root_targets'])
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2778, in Load
    variables, includes, depth, check, True)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 394, in LoadTargetBuildFile
    includes, True, check)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 266, in LoadOneBuildFile
    aux_data, includes, check)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 304, in LoadBuildFileIncludesIntoDict
    subdict_path, include)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2144, in MergeDicts
    MergeDicts(to[k], v, to_file, fro_file)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2137, in MergeDicts
    to[k] = MakePathRelative(to_file, fro_file, v)
  File "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2036, in MakePathRelative
    if item[-1] == '/':
IndexError: string index out of range while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:308:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.10.12-1-MANJARO
gyp ERR! command "/home/antti/.nvm/versions/node/v7.9.0/bin/node" "/home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/node-zopfli-test/node_modules/node-zopfli/lib/binding/node-v51-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/tmp/node-zopfli-test/node_modules/node-zopfli/lib/binding/node-v51-linux-x64"
gyp ERR! cwd /tmp/node-zopfli-test/node_modules/node-zopfli
gyp ERR! node -v v7.9.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/home/antti/.nvm/versions/node/v7.9.0/bin/node /home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/node-zopfli-test/node_modules/node-zopfli/lib/binding/node-v51-linux-x64/zopfli.node --module_name=zopfli --module_path=/tmp/node-zopfli-test/node_modules/node-zopfli/lib/binding/node-v51-linux-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/tmp/node-zopfli-test/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:194:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:899:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Linux 4.10.12-1-MANJARO
node-pre-gyp ERR! command "/home/antti/.nvm/versions/node/v7.9.0/bin/node" "/tmp/node-zopfli-test/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /tmp/node-zopfli-test/node_modules/node-zopfli
node-pre-gyp ERR! node -v v7.9.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.34
node-pre-gyp ERR! not ok 
Failed to execute '/home/antti/.nvm/versions/node/v7.9.0/bin/node /home/antti/.nvm/versions/node/v7.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/node-zopfli-test/node_modules/node-zopfli/lib/binding/node-v51-linux-x64/zopfli.node --module_name=zopfli --module_path=/tmp/node-zopfli-test/node_modules/node-zopfli/lib/binding/node-v51-linux-x64' (1)
npm WARN enoent ENOENT: no such file or directory, open '/tmp/node-zopfli-test/package.json'
npm WARN node-zopfli-test No description
npm WARN node-zopfli-test No repository field.
npm WARN node-zopfli-test No README data
npm WARN node-zopfli-test No license field.
npm ERR! Linux 4.10.12-1-MANJARO
npm ERR! argv "/home/antti/.nvm/versions/node/v7.9.0/bin/node" "/home/antti/.nvm/versions/node/v7.9.0/bin/npm" "install" "node-zopfli"
npm ERR! node v7.9.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-zopfli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-zopfli
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-zopfli
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/antti/.npm/_logs/2017-05-05T05_13_12_409Z-debug.log

Simpler API

It would be easier to work with the Zopfli constructor directly (especially when chossing the method dynamically), instead of via the .create*() methods. Why not just make lib/zopfli.js the main script of the module, do module.exports = Zopfli there, and get rid of the other zopfli.js file? (That would also provide the sync methods exactly like before.)

Сannot find module node-v11-linux-x64/zopfli.node (irregular)

Hello I have some irregular issue on Ubuntu 12.04 LTS Precise:
This error occurs while calling zopfli command for example:

$ find pages-* -name '_search.less.css' -o -name '_search.ru.js' | xargs zopfli -i 15
module.js:340
    throw err;
          ^
Error: Cannot find module '/place/sandbox-data/environment/node-zopfli_1.4.0/node_modules/node-zopfli/lib/binding/node-v11-linux-x64/zopfli.node'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/place/sandbox-data/environment/node-zopfli_1.4.0/node_modules/node-zopfli/lib/zopfli.js:7:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/place/sandbox-data/environment/node-zopfli_1.4.0/node_modules/node-zopfli/bin/zopfli:8:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

io.js 3.0 build failure

> [email protected] install /home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli
> node-pre-gyp install --fallback-to-build

make: Entering directory '/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/build'
  CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o
In file included from ../src/zopfli-binding.h:5:0,
                 from ../src/zopfli-binding.cc:3:
../node_modules/nan/nan.h:324:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureHandleOrPersistent(const v8::Local<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) 
                           ^
../node_modules/nan/nan.h:319:17: note: ‘template<class T> v8::Handle<T> Nan::imp::NanEnsureHandleOrPersistent(v8::Handle<T>&)’ previously declared here
   v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                 ^
../node_modules/nan/nan.h:344:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(v8::Handle<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                           ^
../node_modules/nan/nan.h:334:27: note: ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(const v8::Local<T>&)’ previously declared here
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:757:13: error: ‘node::smalloc’ has not been declared
     , node::smalloc::FreeCallback callback
             ^
../node_modules/nan/nan.h:757:35: error: expected ‘,’ or ‘...’ before ‘callback’
     , node::smalloc::FreeCallback callback
                                   ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)’:
../node_modules/nan/nan.h:761:50: error: ‘callback’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                  ^
../node_modules/nan/nan.h:761:60: error: ‘hint’ was not declared in this scope
         v8::Isolate::GetCurrent(), data, length, callback, hint);
                                                            ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)’:
../node_modules/nan/nan.h:768:67: error: no matching function for call to ‘New(v8::Isolate*, const char*&, uint32_t&)’
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
In file included from ../node_modules/nan/nan.h:25:0,
                 from ../src/zopfli-binding.h:5,
                 from ../src/zopfli-binding.cc:3:
/home/ai/.node-gyp/3.1.0/include/node/node_buffer.h:31:40: note: candidate: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Handle<v8::String>, node::encoding) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ai/.node-gyp/3.1.0/include/node/node_buffer.h:31:40: note:   conversion of argument 3 would be ill-formed:
In file included from ../src/zopfli-binding.h:5:0,
                 from ../src/zopfli-binding.cc:3:
../node_modules/nan/nan.h:768:67: error: invalid conversion from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’ [-fpermissive]
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
In file included from ../node_modules/nan/nan.h:25:0,
                 from ../src/zopfli-binding.h:5,
                 from ../src/zopfli-binding.cc:3:
/home/ai/.node-gyp/3.1.0/include/node/node_buffer.h:43:40: note: candidate: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match>
 NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                        ^
/home/ai/.node-gyp/3.1.0/include/node/node_buffer.h:43:40: note:   conversion of argument 2 would be ill-formed:
In file included from ../src/zopfli-binding.h:5:0,
                 from ../src/zopfli-binding.cc:3:
../node_modules/nan/nan.h:768:67: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
     return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
                                                                   ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’:
../node_modules/nan/nan.h:772:29: error: could not convert ‘node::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))’ from ‘v8::MaybeLocal<v8::Object>’ to ‘v8::Local<v8::Object>’
     return node::Buffer::New(v8::Isolate::GetCurrent(), size);
                             ^
../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanBufferUse(char*, uint32_t)’:
../node_modules/nan/nan.h:779:12: error: ‘Use’ is not a member of ‘node::Buffer’
     return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
            ^
zopfli.target.mk:122: recipe for target 'Release/obj.target/zopfli/src/zopfli-binding.o' failed
make: *** [Release/obj.target/zopfli/src/zopfli-binding.o] Error 1
make: Leaving directory '/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ai/.node/iojs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.5-200.fc22.x86_64
gyp ERR! command "/home/ai/.node/iojs/bin/iojs" "/home/ai/.node/iojs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/lib/binding/node-v45-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/lib/binding/node-v45-linux-x64"
gyp ERR! cwd /home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli
gyp ERR! node -v v3.1.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/home/ai/.node/iojs/bin/iojs /home/ai/.node/iojs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/lib/binding/node-v45-linux-x64/zopfli.node --module_name=zopfli --module_path=/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/lib/binding/node-v45-linux-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:764:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.1.5-200.fc22.x86_64
node-pre-gyp ERR! command "/home/ai/.node/iojs/bin/iojs" "/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli
node-pre-gyp ERR! node -v v3.1.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.9
node-pre-gyp ERR! not ok 
Failed to execute '/home/ai/.node/iojs/bin/iojs /home/ai/.node/iojs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/lib/binding/node-v45-linux-x64/zopfli.node --module_name=zopfli --module_path=/home/ai/Dev/amplifr/front/node_modules/gulp-zopfli/node_modules/node-zopfli/lib/binding/node-v45-linux-x64' (1)

/cc @pierreinglebert

The sync API functions seem to call a non-existing method

$ npm view node-zopfli version && node -e "require('node-zopfli').gzip()"
1.0.0


c:\test\node_modules\node-zopfli\lib\zopfli.js:111
  zopfli.deflate(buffer, "gzip", options, callback);
         ^
TypeError: Object #<Object> has no method 'deflate'
    at Function.Zopfli.gzip (c:\test\node_modules\node-zopfli\lib\zopfli.js:111:10)
    at Object.exports.gzip (c:\test\node_modules\node-zopfli\zopfli.js:16:10)
    at [eval]:1:24
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:532:25)
    at startup (node.js:80:7)
    at node.js:901:3

Dont install zopfli during npm install if binary available.

Thanks for the awesome package. Im using this package to compress frontend assets generated using Webpack.
Each time when the package is installed it installs zopfli binary also which slows the entire process.
Is there any way to skip installation of binary(checking if the binary is already available in the machine)?

node-zopfli package installs, but does not run

This is on a MacbookPro:

$ node --version
v12.16.1
$ npm --version
6.13.4
$ uname -a
Darwin MacbookPro.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

The install appears to be good:

$ npm i -g node-zopfli
/usr/local/bin/zopfli -> /usr/local/lib/node_modules/node-zopfli/bin/zopfli
/usr/local/bin/zopflipng -> /usr/local/lib/node_modules/node-zopfli/bin/zopflipng

> [email protected] install /usr/local/lib/node_modules/node-zopfli
> prebuild-install --runtime napi || prebuild-install || node-gyp rebuild

+ [email protected]
added 65 packages from 105 contributors in 2.32s

However, when I try to run:

$ zopflipng test.png
/usr/local/lib/node_modules/node-pre-gyp/lib/util/versioning.js:220
        throw new Error(msg+"package.json must declare these properties: \n" + missing.join('\n'));
        ^

Error: node-zopfli package.json is not node-pre-gyp ready:
package.json must declare these properties: 
binary.module_name
binary.module_path
binary.host
    at Object.validate_config (/usr/local/lib/node_modules/node-pre-gyp/lib/util/versioning.js:220:15)
    at Object.exports.find (/usr/local/lib/node_modules/node-pre-gyp/lib/pre-binding.js:21:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/node-zopfli/bin/zopflipng:9:27)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

pre-compiled versions, HTTP 403 Access Denied on S3 buckets

Trying to install and it fails with this output:

node-pre-gyp http GET https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz
node-pre-gyp http 403 https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(undefined): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http Connection closed while downloading tarball file

Node: v10.5.0
Python: 2.7.15

Doesn't free memory

Hi, Zopfli docs say that out must be freed after use: https://github.com/google/zopfli/blob/6818a0859063b946094fb6f94732836404a0d89a/src/zopfli/zopfli.h#L82-L83

However, there do not appear to be any calls to free in https://github.com/pierreinglebert/node-zopfli/blob/master/src/zopfli-binding.cc

Am I missing something? This would be a pretty massive memory leak -- basically it would mean memory the size of the compressed output is leaked, plus some overhead because zopfli allocates blocks sized with a power of two.

On a somewhat related note, we seem to get spurious segfaults. I'm not entirely sure that they are caused by node-zopfli but I do wonder, has anybody ever run this through valgrind? Since valgrind reports memory leaks, I'm guessing no?

Build fail on windows_NT 6.17601

gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: read ECONNRESET
gyp ERR! stack at errnoException (net.js:905:11)
gyp ERR! stack at TCP.onread (net.js:559:19)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\Program Files (x86)\nodejs\node.exe" "C:\Users\Adminis
trator.BJXX-20140703IN\AppData\Roaming\npm\node_modules\node-gyp\bin\node
-gyp.js" "configure" "--fallback-to-build" "--build-from-source" "--module=C:\U
sers\Administrator.BJXX-20140703IN\AppData\Roaming\npm\node_modules\node-z
opfli\lib\binding\node-v11-win32-x64\zopfli.node" "--module_name=zopfli" "--
module_path=C:\Users\Administrator.BJXX-20140703IN\AppData\Roaming\npm\nod
e_modules\node-zopfli\lib\binding\node-v11-win32-x64"
gyp ERR! cwd C:\Users\Administrator.BJXX-20140703IN\AppData\Roaming\npm\node_mod
ules\node-zopfli
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'c:\Program Files (x86)\nodejs
node.exe C:\Users\Administrator.BJXX-20140703IN\AppData\Roaming\npm\node_modules
\node-gyp\bin\node-gyp.js configure --fallback-to-build --build-from-source --mo
dule=C:\Users\Administrator.BJXX-20140703IN\AppData\Roaming\npm\node_modules\nod
e-zopfli\lib\binding\node-v11-win32-x64\zopfli.node --module_name=zopfli --modul
e_path=C:\Users\Administrator.BJXX-20140703IN\AppData\Roaming\npm\node_modules\n
ode-zopfli\lib\binding\node-v11-win32-x64' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\Users\Administrator.
BJXX-20140703IN\AppData\Roaming\npm\node_modules\node-zopfli\node_modules\node-p
re-gyp\lib\util\compile.js:73:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:98:17)
node-pre-gyp ERR! stack at maybeClose (child_process.js:766:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (child_proces
s.js:833:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "node" "C:\Users\Administrator.BJXX-20140703IN\AppD
ata\Roaming\npm\node_modules\node-zopfli\node_modules\node-pre-gyp\bin\n
ode-pre-gyp" "install" "--fallback-to-build" "--build-from-source"
node-pre-gyp ERR! cwd C:\Users\Administrator.BJXX-20140703IN\AppData\Roaming\npm
\node_modules\node-zopfli
node-pre-gyp ERR! node -v v0.10.35
node-pre-gyp ERR! node-pre-gyp -v v0.6.4
node-pre-gyp ERR! not ok
Failed to execute 'c:\Program Files (x86)\nodejs\node.exe C:\Users\Administrator
.BJXX-20140703IN\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js confi
gure --fallback-to-build --build-from-source --module=C:\Users\Administrator.BJX
X-20140703IN\AppData\Roaming\npm\node_modules\node-zopfli\lib\binding\node-v11-w
in32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\Administrator.B
JXX-20140703IN\AppData\Roaming\npm\node_modules\node-zopfli\lib\binding\node-v11
-win32-x64' (1)

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build -- build-from-source
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the node-zopfli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build --build-from-source
npm ERR! You can get their info via:
npm ERR! npm owner ls node-zopfli
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "c:\Program Files (x86)\nodejs\node.exe" "c:\Program Files
(x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "node-zopfli" "-g"
npm ERR! cwd D:\Test
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

N-API support for node-zopfli

Node 8 has a new experimental feature called N-API which is aimed at reducing maintenance cost for node native addons. Check out this blog for more details on its benefits.

node-zopfli is a popular module, and in order to help the Node.js community make the important transition to N-API, we are hoping you will be able to work with us in order to migrate node-zopfli to N-API. Your support and feedback is important in making this effort a success.

We (N-API team) have built a preliminary port of node-zopfli on top of N-API as part of our effort to understand the API surface used by native modules. We used this port and the port of some other modules to determine which areas to focus on converting to N-API. This port has all of the NAN code removed and replaced by N-API equivalents. While it passes all the node-zopfli unit tests, it might need a bit more refinement before getting merged in. Please take a look if you're interested. I will be happy to answer questions about the port, point to documentation/code, etc. I'm also happy to open a PR if you're happy with the port in it's current shape.

If you like, you can join our WG meeting which happens every Thursday at 1:30 Eastern / 10:30 Pacific US time, to discuss any issues or ask us any questions.

If you don't want to take a dependency on a feature that still has "experimental" status, we understand, and a good option might be to maintain a branch that uses N-API, that is kept mostly up to date with development occurring in node-zopfli/master. We have some precedence to follow with node.bcrypt.js which recently published a N-API version of their module. Of course we'd appreciate feedback about anything we can do to improve the development or migration experience.

Error when using zopflipng

/usr/local/lib/node_modules/node-zopfli/bin/zopflipng:39
zopfli.pngcompress(program.args[0], program.args[1], options);
^
TypeError: Object # has no method 'pngcompress'
at Object. (/usr/local/lib/node_modules/node-zopfli/bin/zopflipng:39:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

can't install 1.1.3 with npm

I can't install the latest version with npm. I'm seeing this:

[brianp@host zopfli-check]$ npm install node-zopfli
npm http GET https://registry.npmjs.org/node-zopfli
npm http 304 https://registry.npmjs.org/node-zopfli
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/nan
npm http GET https://registry.npmjs.org/node-pre-gyp
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/buffer-crc32
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/node-pre-gyp
npm http 304 https://registry.npmjs.org/buffer-crc32
npm http 304 https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/commander

> [email protected] install /home/brianp/src/node-hacking/zopfli-check/node_modules/node-zopfli
> git submodule update --init && node-pre-gyp install --fallback-to-build --build-from-source

fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
npm ERR! weird error 128
npm ERR! not ok code 0

Add LICENSE

And specify it accordingly in package.json too, like

{
  "license": "MIT"
}

Installation fails on CentOS 32-bit (i686), node v4.4.2, npm v2.15.0

Hello,

We are having difficulties installing node-zopfli on CentOS 32-bit (i686) with node at 4.4.2 and npm at 2.15.0.

This is an excerpt of the error message:

npm ERR! Linux 2.6.32-042stab113.21
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--unsafe-perm"
npm ERR! node v4.4.2
npm ERR! npm  v2.15.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the node-zopfli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-zopfli
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls node-zopfli
npm ERR! There is likely additional logging output above.

Attached is the rest of the CLI output, along with the npm_debug.log.

npm_debug.log.zip

CLI_output.zip

Download fails with HTTP=403 (Yarn, Node-Gyp, Mac, Node 7.10)

It seems that right now there is some issues downloading binaries for this package. This is the error I got over the last 30 minutes (retried a few times):

node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | darwin | x64
node-pre-gyp info check checked for "/Users/Sebastian/Workspace/sebastian-software/edgestack/node_modules/node-zopfli/lib/binding/node-v51-darwin-x64/zopfli.node" (not found)
node-pre-gyp http GET https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v51-darwin-x64.tar.gz
node-pre-gyp http 403 https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v51-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v51-darwin-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v51 ABI) (falling back to source compile with node-gyp) 
node-pre-gyp http 403 status code downloading tarball https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v51-darwin-x64.tar.gz 
  • node --version: v7.10.0
  • yarn --version: 0.24.5
  • npm --version: 4.6.1

Hopefully someone has an idea where this is coming from. Thanks a lot!

npm install node-zopfli failed

[root@localhost node-zopfli]# cnpm install
node-pre-gyp http GET https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.1-node-v48-linux-x64.tar.gz
node-pre-gyp http 403 https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.1-node-v48-linux-x64.tar.gz
node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.1-node-v48-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v48 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.1-node-v48-linux-x64.tar.gz
make: Entering directory `/opt/node/lib/node_modules/node-zopfli/build'
  CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o
In file included from ../src/zopfli-binding.h:5,
                 from ../src/zopfli-binding.cc:3:
../node_modules/.2.4.0@nan/nan.h:43:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /root/.node-gyp/6.9.1/include/node/node.h:42,
                 from ../src/zopfli-binding.cc:1:

Python 2.7.6
gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
node v6.9.1
npm 3.10.8

Cannot install inside Docker container

Hi,

I wanted to install node-zopfli inside a Debian Jessie based Docker container and got the below error.

With the same dependencies on a normal VM that runs the Debian Jessie, the installation works just fine.

Does anyone of you have an idea what the container might be missing that does not allow node-zopfli to be installed correctly?

Dependencies:

$ node --version
v6.9.4

$ npm --version
3.10.10

$ gcc --version
gcc (Debian 4.9.2-10) 4.9.2

$ python --version
Python 2.7.9

$ make --version
GNU Make 4.0

$ npm -g ls --depth=0
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
/usr/local/lib
+-- [email protected]
`-- [email protected]

Error:

$ npm install -g node-zopfli

...
gyp info using [email protected] | linux | x64
make: Entering directory '/usr/local/lib/node_modules/node-zopfli/build'
make: *** No rule to make target '../.node-gyp/6.9.4/include/node/common.gypi', needed by 'Makefile'.  Stop.
make: Leaving directory '/usr/local/lib/node_modules/node-zopfli/build'
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.9.4-moby
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/node-zopfli/lib/binding/node-v48-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/usr/local/lib/node_modules/node-zopfli/lib/binding/node-v48-linux-x64"
gyp ERR! cwd /usr/local/lib/node_modules/node-zopfli
gyp ERR! node -v v6.9.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/node-zopfli/lib/binding/node-v48-linux-x64/zopfli.node --module_name=zopfli --module_path=/usr/local/lib/node_modules/node-zopfli/lib/binding/node-v48-linux-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/node-zopfli/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Linux 4.9.4-moby
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-zopfli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/node-zopfli
node-pre-gyp ERR! node -v v6.9.4
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/node-zopfli/lib/binding/node-v48-linux-x64/zopfli.node --module_name=zopfli --module_path=/usr/local/lib/node_modules/node-zopfli/lib/binding/node-v48-linux-x64' (1)
npm info lifecycle [email protected]~install: Failed to exec install script
npm ERR! Linux 4.9.4-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "node-zopfli"
npm ERR! node v6.9.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-zopfli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-zopfli
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-zopfli
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log

Here is my Dockerfile:

FROM buildpack-deps:jessie

RUN groupadd --gid 1000 node \
  && useradd --uid 1000 --gid node --shell /bin/bash --create-home node

# gpg keys listed at https://github.com/nodejs/node
RUN set -ex \
  && for key in \
    9554F04D7259F04124DE6B476D5A82AC7E37093B \
    94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
    0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
    FD3A5288F042B6850C66B31F09FE44734EB7990E \
    71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
    DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
    B9AE9905FFD7803F25714661B63B535A4C206CA9 \
    C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  ; do \
    gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
  done

ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 6.9.4

RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
  && curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
  && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
  && grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
  && tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
  && rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
  && ln -s /usr/local/bin/node /usr/local/bin/nodejs

CMD [ "node" ]

"npm install node-zopfli" fails

Perhaps the AWS usage has been exceeded?

npm install node-zopfli

[email protected] install C:\Repos\edgepushsample\node_modules\gulp-zopfli\node_modules\node-zopfli
node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v57-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! configure error

Fails to compile (on MacOS) with Node 10

node: v10.9.0
node-gyp: v3.7.0

Works fine with node 8 and 9.

Some of the people in #87 might actually be experiencing this issue instead.

❯ npm i -S node-zopfli

> [email protected] install /Users/alextes/code/zopfli/node_modules/node-zopfli                                                                    
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz                    
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v64-darwin-x64.tar.gz              
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
  CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o
  CXX(target) Release/obj.target/zopfli/src/zopfli-binding.o
../src/zopfli-binding.cc../src/zopfli-binding.cc::137137::1515::  warningwarning: : 'Call' 'Call'is  isdeprecated  deprecated[-Wdeprecated-declarations] [-Wdeprecated-declarations]

    callback->Call(2, argv);
              ^
    callback->Call(2, argv);
              ^
../../nan/nan.h:1646:3: note../../nan/nan.h: :1646'Call': 3has:  been explicitlynote : marked deprecated'Call'  herehas                            
been explicitly marked deprecated here  NAN_DEPRECATED inline v8::Local<v8::Value>                                                                 

  ^
../../nan/nan.h:102:40:   NAN_DEPRECATED inline v8::Local<v8::Value>
note:   ^
expanded from macro 'NAN_DEPRECATED'
../../nan/nan.h:102:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
# define NAN_DEPRECATED __attribute__((deprecated))
                                       ^
1 warning generated.
1 warning generated.
rm: ./Release/.deps/Release/obj.target/zopfli/src/zopfli-binding.o.d.raw: No such file or directory                                                
make: *** [Release/obj.target/zopfli/src/zopfli-binding.o] Error 1
gyp   CXX(target) Release/obj.target/zopfli/src/png/zopflipng.o
ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/alextes/.nvm/versions/node/v10.9.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:239:12)                                                       
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/alextes/.nvm/versions/node/v10.9.0/bin/node" "/Users/alextes/.nvm/versions/node/v10.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64/zopfli.node" "--module_name=zopfli" "--module_path=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64"           
gyp ERR! cwd /Users/alextes/code/zopfli/node_modules/node-zopfli
gyp ERR! node -v v10.9.0
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/alextes/.nvm/versions/node/v10.9.0/bin/node /Users/alextes/.nvm/versions/node/v10.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64/zopfli.node --module_name=zopfli --module_path=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/alextes/code/zopfli/node_modules/node-pre-gyp/lib/util/compile.js:83:29)           
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:961:16)                                                                       
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)                                               
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/Users/alextes/.nvm/versions/node/v10.9.0/bin/node" "/Users/alextes/code/zopfli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/alextes/code/zopfli/node_modules/node-zopfli
node-pre-gyp ERR! node -v v10.9.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/Users/alextes/.nvm/versions/node/v10.9.0/bin/node /Users/alextes/.nvm/versions/node/v10.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64/zopfli.node --module_name=zopfli --module_path=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64' (1)                  npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`                                                                     
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                                                 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alextes/.npm/_logs/2018-09-06T06_51_53_364Z-debug.log

../src/png/zopflipng.cc:3:10: fatal error: 'nan.h' file not found
#include "nan.h"
         ^~~~~~~
1 error generated.
make: *** [Release/obj.target/zopfli/src/png/zopflipng.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/alextes/.nvm/versions/node/v10.9.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:239:12)                                                       
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/Users/alextes/.nvm/versions/node/v10.9.0/bin/node" "/Users/alextes/.nvm/versions/node/v10.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64/zopfli.node" "--module_name=zopfli" "--module_path=/Users/alextes/code/zopfli/node_modules/node-zopfli/lib/binding/node-v64-darwin-x64"           
gyp ERR! cwd /Users/alextes/code/zopfli/node_modules/node-zopfli
gyp ERR! node -v v10.9.0
gyp ERR! node-gyp -v v3.7.0

Allow overriding image file.

BTW, doing zopflipng foo.png foo.png seems to work fine?

Although, we should somehow prevent writing a bigger image.

node-zopfli package install, but does not run

This is on a MacBook Pro:

$ node --version
v12.16.1
$ npm --version
6.13.4
$ uname -a
Darwin MacbookPro.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

The install appears to be good:

$ npm i -g node-zopfli
/usr/local/bin/zopflipng -> /usr/local/lib/node_modules/node-zopfli/bin/zopflipng
/usr/local/bin/zopfli -> /usr/local/lib/node_modules/node-zopfli/bin/zopfli

> [email protected] install /usr/local/lib/node_modules/node-zopfli
> prebuild-install --runtime napi || prebuild-install || node-gyp rebuild

+ [email protected]
updated 2 packages in 4.968s
$ zopflipng --version
2.1.4

However, when I try to run:

$ zopflipng test.png test-zopfli.png
/usr/local/lib/node_modules/node-zopfli/bin/zopflipng:49
  zopfli.pngcompress(program.args[0], program.args[1], options);
         ^

TypeError: undefined is not a function
    at Object.<anonymous> (/usr/local/lib/node_modules/node-zopfli/bin/zopflipng:49:10)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

Doesn't install on a vagrant mounted share if host is windows

Hey

Works like a charm on my mac. Thank you very much for this module.

But my colleagues who are running their vagrant VM on windows get this:

npm ERR! Error: UNKNOWN, symlink '../node-pre-gyp/bin/node-pre-gyp'

This is with the --no-bin-links flag set.

Cheers

N

Node 0.11

Buffer API has changed in node 0.11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.