Alorel / shrink-ray

Node.js compression middleware
MIT License
177 stars 16 forks source link

GZIP fallback #48

Open krystian50 opened 4 years ago

krystian50 commented 4 years ago

Hi,

I'm getting an error ERROR (node:1) [ZOPFLI_COMPAT] MISSING_MODULE: Module "node-zopfli-es" was unavailable Zopfli compression unavailable; will fall back to gzip.

Any tips?

The package is added through "optionalDependencies": { "iltorb": "~2.0.0", "node-zopfli-es": "~1.0.3" },

kriscarle commented 4 years ago

@krystian50 check for error messages from npm install node-zopfli-es likely you are missing a prerequisite, it needs python, make, gcc, g++ etc. depending on the platform, see the notes at https://github.com/jaeh/node-zopfli-es

Since it is an "optional" dependency NPM will skip over it if there is an error so a full npm install will still complete.

H-Gomez commented 4 years ago

@krystian50 were you able to resolve this warning as we are getting it also. Installed zopfli@1.0.3 directly with Yarn, no problems there.

On building the project I get a similar error:

warning  in ./node_modules/node-zopfli-es/lib/zopfli.js
Critical dependency: the request of a dependency is an expression
(node:10881) [ZOPFLI_COMPAT] MISSING_MODULE: Module "node-zopfli-es" was unavailable
Zopfli compression unavailable; will fall back to gzip.
kriscarle commented 4 years ago

@H-Gomez @krystian50 any chance you are using Docker? or developing on a different platform and copying your node_modules? I just got this error on a new project because I forgot to add the .dockerignore ignoring node_modules and it was overwriting the native linux build with the files from my Mac.

You can get a better error message by running node -p "require('node-zopfli-es');" In my case I saw zopfli.node: Exec format error

H-Gomez commented 4 years ago

@kriscarle No docker is being used on the local development environment. The platform is Mac OSX (10.14) on Node 10.13 and I've removed the node modules and done a fresh yarn to get all the packages installed again with no resolution.

When running the above command in the project root it returns the Zopli class indicating that it's able to find the package source correctly.

node -p "require('node-zopfli-es');"
{ [Function: Zopfli]
  createGzip: [Function],
  createZlib: [Function],
  createDeflate: [Function],
  compress: [Function],
  gzip: [Function],
  zlib: [Function],
  deflate: [Function],
  gzipSync: [Function],
  zlibSync: [Function],
  deflateSync: [Function] }

I can manually edit the zopli-compat.js inside of node_modules/shrink-ray-current/ to log out the error in the catch statement which gives me:

 warning  in ./node_modules/node-zopfli-es/lib/zopfli.js
(node:31489) [MODULE_NOT_FOUND] Error: Cannot find module './binding/zopfli.node'

This to me is confusing as I can see the zopfli.node file exists in node_modules/node-zopfli-es/lib/binding/. Not entirely sure what else to try here.

kriscarle commented 4 years ago

@H-Gomez Possibly something odd on your machine like a permissions issue? I'd recommend setting up a very simple hello world express app, then add shrink-ray-current to that and see if this happens in the simplest test case. If so, you could try upgrading NodeJS (10.13 is from October 2018) or use nvm or Docker to test different environments.