DEV Community

Cover image for How to set up Nodemon & Sucrase
Antoniel Magalhães
Antoniel Magalhães

Posted on

11 2

How to set up Nodemon & Sucrase

What is Sucrase?

Sucrase let us develop Node app in ES6,is an alternative to Babel that allows super-fast development builds. If it fits your use case, hopefully, Sucrase can speed up your development experience!

What is Nodemon?

Nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.

Getting Start

First you need to install the packages as development dependencies,

yarn add --dev sucrase 
yarn add --dev nodemon
# Or 
npm install --save-dev sucrase
npm install --save-dev nodemon
Enter fullscreen mode Exit fullscreen mode

After setting the packages as project dependencies, if we try to use the features of Sucrase like this:

node index.js
#Or
nodemon index.js
Enter fullscreen mode Exit fullscreen mode

You will encounter an error because to compile with sucrase, is necessary use sucrase-node instead node, on use nodemon node is called every time some file change in a directory, so how we set to nodemon use sucrase-node instead node?

Nodemon + Sucrase

To set Nodemon to use sucrase we need to create a file nodemon.json in our '/' project, with the following code:

{
  "execMap":{
    "js": "node -r sucrase/register"
  }
}
Enter fullscreen mode Exit fullscreen mode

Once we create this file every time nodemon executes a js file, it will be compiled by sucrase before run the code.

References

https://www.npmjs.com/package/sucrase

https://www.npmjs.com/package/nodemon

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay