Z_DATA_ERROR, ERRNO -3, zlib: incorrect data check, MBA M1
Asked Answered
E

3

14

Recently I face an issues to install my dependencies using latest Node and NPM on my MacBook Air M1 machine. Then I found out M1 is not supported latest Node version. So my solution, to using NVM and change them to Node v14.16

Everything works well, but when our team apply new eslint configuration. Yet, I still not sure whether eslint was causes the error or not.

.eslintrc

{
  "env": {
    "es6": true,
    "browser": true,
    "node": true
  },
  "extends": ["eslint:recommended", "plugin:react/recommended"],
  "parser": "@babel/eslint-parser",
  "parserOptions": {
    "requireConfigFile": false,
    "ecmaVersion": 2018,
    "sourceType": "module",
    "ecmaFeatures": {
      "impliedStrict": true,
      "jsx": true
    }
  },
  "plugins": ["react", "prettier", "@babel"],
  "rules": {
    // "prettier/prettier": [
    //   "warn",
    //   {
    //     "endOfLine": "auto",
    //   }
    // ],
    "no-console": 1,
    "indent": [
      2,
      2,
      {
        "SwitchCase": 1
      }
    ],
    "linebreak-style": 0,
    "quotes": [2, "single"],
    "semi": 0,
    "curly": [2, "all"],
    "camelcase": "off",
    "react/display-name": "off",
    "eqeqeq": [2, "smart"],
    "one-var-declaration-per-line": [2, "always"],
    "new-cap": 2,
    "no-case-declarations": 0
  },
  "globals": {
    "axios": true,
    "PropTypes": true
  },
  "settings": {
    "import/resolver": {
      "alias": [["./src/"]]
    }
  }
}

This error was occurred:

Error

npm ERR! code Z_DATA_ERROR
npm ERR! errno -3
npm ERR! zlib: incorrect data check

Log

5147 silly saveTree └── [email protected]
5148 verbose stack ZlibError: zlib: incorrect data check
5148 verbose stack     at Unzip.write (/Users/metalheadcoder/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/minizlib/index.js:147:22)
5148 verbose stack     at Object.write (/Users/metalheadcoder/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:305:58)
5148 verbose stack     at PassThrough.ondata (internal/streams/readable.js:719:22)
5148 verbose stack     at PassThrough.emit (events.js:315:20)
5148 verbose stack     at addChunk (internal/streams/readable.js:309:12)
5148 verbose stack     at readableAddChunk (internal/streams/readable.js:284:9)
5148 verbose stack     at PassThrough.Readable.push (internal/streams/readable.js:223:10)
5148 verbose stack     at PassThrough.Transform.push (internal/streams/transform.js:166:32)
5148 verbose stack     at PassThrough.afterTransform (internal/streams/transform.js:101:10)
5148 verbose stack     at PassThrough._transform (internal/streams/passthrough.js:46:3)
5148 verbose stack     at PassThrough.Transform._read (internal/streams/transform.js:205:10)
5148 verbose stack     at PassThrough.Transform._write (internal/streams/transform.js:193:12)
5148 verbose stack     at writeOrBuffer (internal/streams/writable.js:358:12)
5148 verbose stack     at PassThrough.Writable.write (internal/streams/writable.js:303:10)
5148 verbose stack     at Readable.ondata (internal/streams/readable.js:719:22)
5148 verbose stack     at Readable.emit (events.js:315:20)
5149 verbose cwd /Users/metalheadcoder/Gitlab/warefe
5150 verbose Darwin 21.1.0
5151 verbose argv "/Users/metalheadcoder/.nvm/versions/node/v14.16.1/bin/node" "/Users/metalheadcoder/.nvm/versions/node/v14.16.1/bin/npm" "install"
5152 verbose node v14.16.1
5153 verbose npm  v6.14.12
5154 error code Z_DATA_ERROR
5155 error errno -3
5156 error zlib: incorrect data check
5157 verbose exit [ -3, true ]

Machine

MacBookAir M1 2020

Approach

  • Install package using nvm use v14
  • Install package using nvm use v16
  • Install package using nvm use v17
  • Remove node_modules and package-lock.js also run npm cache clean --force

Thank you in advance.

Exaggerative answered 1/11, 2021 at 6:34 Comment(3)
That doesn't necessarily look M1-specific; it's possible that some package Node is trying to decompress is simply corrupted.Oxbridge
Thanks, you just gimme an idea. I reinstall node v14.16.1. And now works perfectly fine. :)Exaggerative
In my case, downgrading to version 14.17 didn't help. I installed dependencies using version 16 (nvm use 16) then switched back to version 14 (nvm use 14)Priscillaprise
U
15

I had a similar problem with another module.

The solution I found was to update both node (to v16) and npm (to v8).

For Node, I used brew (but nvm should be OK).

For npm, I used what the official doc says :

npm install -g npm@latest

Unconventional answered 15/11, 2021 at 11:46 Comment(5)
The worst thing in regards to your answer is that it is correct. Updated from 8.1 to 8.5 and this issue was sorted.Gateway
is there a way to do this without upgrading the versions? my project is set to work with older versions only.Tonjatonjes
@Tonjatonjes try reinstallHeine
thanks the issue was related to setting up my project without rosetta.Tonjatonjes
thanks, I probably download some different package by running yarn install by accident and that created the conflict. This seems to have reset the packages, now I'm not sure why, does it refetch everything by default? what if there wasn't a new version available? or maybe it was just a bug that got actually fixed later on, I couldn't reproduce the error afterwards and the logs got deleted by updating hahahaCrichton
R
1

On my mac running "npm install" (for example) three (or more) times worked.

Ruddock answered 13/11, 2022 at 12:37 Comment(3)
how does repeating the same command thrice solve the problem?Adamson
It works also only on some things like "npm install -g npm@latest", but not always. That's a bit strange…Ruddock
I hate that this is sometimes true.Emotionalism
G
0

As you can see on my comment above, once it worked for me when updating from 8.1 to 8.5 but it stopped working (I don't know why). The solution was downloading the binary nodejs 16 from the official website rather than compiling npm by myself. I assume that there is any trick when building node from source.

Gateway answered 5/6, 2022 at 6:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.