Resolving a failing NX post-install

profile
Tim Deschryver
timdeschryver.dev

After migration our build pipelines to GitHub Actions, we started to see randomly failing build steps with the following error message:

Looking at the error it's clear that the post-install step of the nx package is the cause of the problem. Sadly, the error message is not very helpful... I tried to find more information about the error code 135, but I couldn't find anything useful.

At first, I thought it was an issue on nx's side and that an update to the latest version would help. But alas, after updating to the latest version of nx, the problem was still there.

Retriggering the build fixed the problem, but it was not a reliable solution and caused some delays while creating and reviewing pull requests.

A potential workaround link

After browsing though the GitHub issues I noticed we weren't the only ones experiencing this issue. A popular workaround mentioned in the comments is to change the install script to skip the post-install step using the --ignore-scripts flag.

While this a solution, I don't like the idea of skipping the post-install step. In scenarios where a post-install step is crucial, this workaround is not be an option. I also thought NX relies on this step for a reason, so skipping it might cause other issues down the line, which I wanted to avoid.

The better solution link

It was only after running npm ls nx that I noticed different versions of nx were installed in the project (through dependencies).

Note

The npm-ls command will print to stdout all the versions of packages that are installed, as well as their dependencies when --all is specified, in a tree structure.

After making sure our project and its dependencies were using the same version of nx, the problem disappeared. I expect the issue was caused by the different versions of nx that started multiple concurrent processes to run the post-install step at the same time, which were locking each other up.

Feel free to update this blog post on GitHub, thanks in advance!

Join My Newsletter (WIP)

Join my weekly newsletter to receive my latest blog posts and bits, directly in your inbox.

Support me

I appreciate it if you would support me if have you enjoyed this post and found it useful, thank you in advance.

Buy Me a Coffee at ko-fi.com PayPal logo

Share this post