Gitlab CI/CD: npm ERR! code ELIFECYCLE
The goal of this post is just to share an issue I got with his solution.
Issue
My app building returns an unexpected error when executed on a CI server. However, it works on any other environments.
I just wanted to build my React app on my own Gitlab runner instance. Strangely, after the succeeded build, npm returned an unexpected error without any more details.
Funny thing, as I said everything works fine on my local machine and on a brand new Docker container (node 12, 14) built and ran on the server.
A log extract is worth a thousand words:
|
|
Investigation
By knowing that, the problem is obviously the environment. But to figure it out, I first need to get more context. Unfortunately, it’s impossible to investigate the container and his logs due to the runner environment which removes the container after getting the error. As I can only see the job logs, I can use –verbose npm tough, in order to get more information about what happened. Finally, by reading carefully the logs, I find a very interesting line:
|
|
And lower… a missed warning! Gotcha!
Conclusion
Always consider warnings as errors locally, most CI environments don’t allow them by setting their environment variables automatically.
Reducing the technical differences between the different involved machines is a must for saving time and energy.
I hope your learned something, have a great day!