NPM Hanging And Typescript Issues With Monterey OS

Photo by Natalie Chaney on UnsplashRecently I’ve run into issues where NPM would refuse to install. It kept hanging, and blowing away node_module folder or clearing the NPM cache didn’t work. If you ever find yourself in this situation, here are some s…


This content originally appeared on Level Up Coding - Medium and was authored by Lennant

Photo by Natalie Chaney on Unsplash

Recently I’ve run into issues where NPM would refuse to install. It kept hanging, and blowing away node_module folder or clearing the NPM cache didn’t work. If you ever find yourself in this situation, here are some sure-fire ways to get you productive again.

NPM Hanging Issue

The first type of issue that lost me quite a bit of time resolving until I finally tried step 4 was due to a complex lerna project setup. No matter what I did, I lost the ability to install the application. To save you some time, here are some steps to try when you come across similar issues.

  1. First try blowing away your node_modules folder and re-install using npm ci.
  2. Clear the NPM cache using npm cache clean --force and re-install by following step 1.
  3. See if its related to your package-lock.json file by deleting it and running npm install.
  4. If none of these steps work, time for the nuclear option.
    On Mac, open finder, select Go Menu -> Go To Folder, type in ~/ to go to your home directory. Hit Cmd + Shift + . to show hidden files. Then delete .npmfolder.
    Windows users, I haven’t verified this but you should be able to clean up NPM by removing these folders C:\Users\YOUR_USER_NAME\AppData\Roaming\npm
    C:\Users\YOUR_USER_NAME\AppData\Roaming\\npm-cache

Monterey OS Typescript Issues

I recently had a colleague whose laptop updated to the latest OS and found themselves unable to be productive due to a random set of errors. Hopefully Apple or Node will address the root causes in the near future. Until then, here are some workarounds.

The first type of error is the Z_DATA_ERROR.

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

If you start getting this, you’ll need to downgrade your version of node. As to what version that is, see this relevant post for more info.

https://stackoverflow.com/questions/69452504/zlib-error-when-attempting-to-run-npm-install-or-yarn

The second type of error is when you start to get a random typescript failure with your code.

The solution here was to bump down the version of typescript that was in use to v4.0.3. This eliminated the typescript issue.

In conclusion, I hope this article is of help to some of you. It would have saved me a couple of days of frustration had I known these tips upfront.


NPM Hanging And Typescript Issues With Monterey OS was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Lennant


Print Share Comment Cite Upload Translate Updates
APA

Lennant | Sciencx (2022-03-09T02:32:21+00:00) NPM Hanging And Typescript Issues With Monterey OS. Retrieved from https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/

MLA
" » NPM Hanging And Typescript Issues With Monterey OS." Lennant | Sciencx - Wednesday March 9, 2022, https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/
HARVARD
Lennant | Sciencx Wednesday March 9, 2022 » NPM Hanging And Typescript Issues With Monterey OS., viewed ,<https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/>
VANCOUVER
Lennant | Sciencx - » NPM Hanging And Typescript Issues With Monterey OS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/
CHICAGO
" » NPM Hanging And Typescript Issues With Monterey OS." Lennant | Sciencx - Accessed . https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/
IEEE
" » NPM Hanging And Typescript Issues With Monterey OS." Lennant | Sciencx [Online]. Available: https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/. [Accessed: ]
rf:citation
» NPM Hanging And Typescript Issues With Monterey OS | Lennant | Sciencx | https://www.scien.cx/2022/03/09/npm-hanging-and-typescript-issues-with-monterey-os/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.