I have just made some pulls from my library's from GitHub, I was using my windows computer to do the coding in VSCode. The code has no problem, although when I attempt to run npm install or yarn install to get the node_modules and the yarn.lock I get a weird error and the packages don't work. I'm using ZSH as the terminal for my Mac.
This is the error output:
niltonsf@Niltons-MacBook-Pro ignews.nosync % sudo yarn install
Password:
yarn install v1.22.15
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz: incorrect data check".
info If you think this is a bug, please open a bug report with the information provided in "/Users/niltonsf/Desktop/ignews.nosync/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz: incorrect data check
error https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.2.tgz: incorrect data check
niltonsf@Niltons-MacBook-Pro ignews.nosync % npm install
npm WARN deprecated @types/next-auth@3.15.0: This is a stub types definition. next-auth provides its own type definitions, so you do not need this installed.
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm ERR! code Z_DATA_ERROR
npm ERR! errno -3
npm ERR! zlib: incorrect data check
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/niltonsf/.npm/_logs/2021-10-05T15_44_51_340Z-debug.log
niltonsf@Niltons-MacBook-Pro ignews.nosync %
My versions from node, npm and yarn:
node: v14.18.0
npm: 6.14.15
yarn: 1.22.15
macos: Big Sur
What I have attempted:
deleting the yarn.lock
running: npm cache verify and then npm cache clean --force
This is the end of the log result:
1165 verbose stack at PassThrough.Writable.write (internal/streams/writable.js:303:10)
1165 verbose stack at PassThrough.ondata (internal/streams/readable.js:731:22)
1165 verbose stack at PassThrough.emit (events.js:400:28)
1166 verbose cwd /Users/niltonsf/Desktop/github.nosync/ignews
1167 verbose Darwin 20.6.0
1168 verbose argv "/usr/local/Cellar/node@14/14.18.0/bin/node" "/usr/local/opt/node@14/bin/npm" "install"
1169 verbose node v14.18.0
1170 verbose npm v6.14.15
1171 error code Z_DATA_ERROR
1172 error errno -3
1173 error zlib: incorrect data check
1174 verbose exit [ -3, true ]
If I run the npm i or yarn in my windows computer I dont get any error
After facing similar issues on some of our workstations, I would say that it definitely looks like a bug in Node 14.18.x on m1 Macs and/or Big Sur (even though node
itself is compiled for x86_64
). I suspect a linking issue with the zlib library, but this is a discussion for Node's issue tracker...
So here's my suggestion: uninstall Node 14.18.x and try using Node 14.17.x instead.
As a side note, you may find it useful to first install nvm. nvm
allows to quickly install several versions of Node, and switch from one to the other. For example, you might do:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 14.17
nvm alias default 14.17
npm install -g yarn
yarn