Installing Packages
Now that we have our base project, we need some packages! NPM packages are libraries or modules that JavaScript developers can use to add functionality and features to their applications.
NPM stands for Node Package Manager, a registry of NodeJS packages created by GitHub. It is mainly community-run. However, in this guide, we are using Bun, a modern alternative to NPM and Yarn, known for its speed and efficiency.
Since we are creating an API, we will use the ExpressJS package, which makes it easy to create APIs. To install packages in Bun, we use the following command:
You can install multiple packages at once by listing them in a single command. For example, to install the ExpressJS package, use the command:
Now, some packages do not include TypeScript type definitions by default. These type definitions provide intellisense and autocompletion support in development environments. ExpressJS, for instance, is a native JavaScript package and does not come with built-in TypeScript support.
To add type definitions for such packages, we can use the following command with Bun:
For ExpressJS, the specific command would be:
Here, the -D
flag installs the package as a development dependency, meaning it will only be used during development and will not be included in the production build.
Last updated