metalheadcoder
metalheadcoder

Reputation: 525

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

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

Thank you in advance.

Upvotes: 14

Views: 24971

Answers (3)

jsGuru
jsGuru

Reputation: 21

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

Upvotes: 1

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.

Upvotes: 0

pom421
pom421

Reputation: 1964

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

Upvotes: 15

Related Questions