DEV Community

Antonio
Antonio

Posted on • Updated on

Essential packages for Node.js newbies

Finding packages in NPM that solve certain problem or that just can make your life easier as a developer can be difficult, and even more if you're new to Node.js.

When I started learning Node I asked some of my friends (which were already working in JS projects) to tell me the packages they used the most so I could level up my skills. The list I got was very basic and I've been adding more packages to it whenever I've found the need to use them.

Searching here I found this post by @ben from last year and, although people suggested a lot of very useful packages, I think they are mostly for advance users.

I know this list is very short so maybe we can improve it together!

Backend:
- express: web application server framework
- body-parser: middleware for express
- hapi: another web framework with built in plugins for auth, caching, cookies... (@Jeremy Shore)
- axios: to send http requests.
- dotenv: load variables from a .env file as environment variables. Super useful to load different database details depending on local, staging and production.

Database:
- mongoose - Interact with MongoDB
- json-server - Creates a fake REST API from a JSON file. Super useful when working in front-end projects or to mock an external API.

Security, encrypt:
- jsonwebtoken: to generate ,validate and decode JWT
- bcrypt: encryption functions

Testing
- mocha: Testing framework
- chai: Assertion library
- jest: another test framework with coverage reports built in (@joelnet )
- chai-http: send http requests from your tests
- sinon: To create stubs
- nock: To create mocks
- nyc: To generate test coverage reports

Others:
- amqplib: For Rabbit MQ
- debug: prints debug messages in console
- watson: another debug library, has different levels of debug
- url: to parse URLs
- moment: to format dates
- lodash: helper functions to work with arrays, objects, numbers...

Plugins/code formatters:
- nodemon: restart app when changing files
- prettier
- eslint

What do you guys think? Which are the essential packages you think a newbie should know about? I'll try to keep this list updated as much as I can so it can be helpful to others :)

Top comments (4)

Collapse
 
joelnet profile image
JavaScript Joel

I would recommend Jest for testing. I have switched from other test frameworks to Jest because it has a lot of things built in. The big one I always setup is istanbul. Jest has this configured automatically by just adding a flag jest --coverage. It has saved me a lot of setup time.

Collapse
 
uf4no profile image
Antonio

Thanks for sharing! I didn't knew Jest could generate coverage reports out of the box.
I'll include it to the list :)

Collapse
 
w9jds profile image
Jeremy Shore

Why use axios when you can just use the built-in fetch functionality with @babel/polyfill? Also, I would recommend maybe hapi as well, since I have seen it used quite a bit as well.

Collapse
 
uf4no profile image
Antonio

Thanks! I'll check how to use fetch :)
I've added hapi to the list (didnt knew about it...)