One thing I'm learning as a software developer is that installing dependencies is not just about running commands in the terminal. It's also about understanding what each package does and knowing how to troubleshoot when something doesn't go as expected.
While setting up my backend project with Node.js, Express, TypeScript and MongoDB, I encountered a warning from pnpm:
"Ignored build scripts."
Initially, I wasn't sure what was happening, so I decided to investigate and understand the reason behind it.
Here's what I learned along the way.
1. Understanding the dependencies I was installing
I was installing development dependencies using:
pnpm add -D typescript tsx @types/node @types/express @types/multer But what exactly do these packages do?
- TypeScript: Allows us to write JavaScript with static type checking, helping us identify potential errors during development.
- tsx: Allows us to execute TypeScript files directly during development without manually compiling them first.
- @types/node: Provides TypeScript type definitions for Node.js APIs.
- @types/express: Provides TypeScript type definitions for Express.
- @types/multer: Provides TypeScript type definitions for Multer.
I also learned the difference between production and development dependencies.
Production dependencies are required when running the application, while development dependencies provide tools that help us write, check and execute our code during development.
2. Understanding the pnpm warning
This was where things became interesting.
I initially thought I had encountered an installation error, but I discovered that it was related to a security feature in newer versions of pnpm.
pnpm can block dependency lifecycle scripts unless they have been explicitly approved.
But what are build scripts?
Some packages need to execute scripts during installation to prepare their binaries or other resources.
In my case, the package involved was esbuild.
3. What exactly is esbuild?
esbuild is a fast JavaScript bundler and build tool.
It helps transform and bundle JavaScript and TypeScript code efficiently.
It is commonly used within modern frontend development tools and build systems, including Vite.
This helped me understand why esbuild was involved in my project setup.
4. How I approached the problem
My first step was to run:
pnpm approve-builds This command opens an interactive selection menu where you can choose which dependencies are allowed to execute their build scripts.
I was supposed to press the Spacebar to select esbuild before pressing Enter.
However, I pressed Enter without selecting it.
As a result, the package wasn't approved.
That was an important lesson for me: understanding what a command does is just as important as knowing how to execute it.
5. Correcting the configuration
I then examined my pnpm-workspace.yaml file.
I found the build permission configuration and updated it to allow esbuild:
allowBuilds: esbuild: true This explicitly approves esbuild's build script.
After saving the configuration, I returned to my terminal and ran:
First:
pnpm install This applies the dependency configuration and ensures the installation is up to date.
Next:
pnpm rebuild esbuild This rebuilds esbuild so that its required installation scripts can run.
6. Verifying the installed dependencies
Finally, I ran:
pnpm list This allowed me to inspect the dependencies installed in my project and confirm that the packages I needed were present.
My biggest takeaways
This experience taught me several important lessons:
- Not every warning is necessarily an application error.
- Package managers have security features that developers need to understand.
- Every dependency has a purpose, and we should understand why we're installing it.
- Reading terminal messages carefully can save time when troubleshooting.
- Learning how to configure tools is an important part of backend development.
I'm beginning to appreciate that becoming a better developer isn't just about writing code. It's also about understanding the tools, configurations and processes that make our applications work.
And this is one of the reasons I'm developing an interest in technical writing.
I want to document what I learn, explain technical concepts in simple terms, and make my learning experiences useful to other developers, especially beginners.
One concept at a time. One command at a time. One problem at a time. ❤️
