DEV Community

Cover image for do you prefer Makefile or package.json
Simone Gentili
Simone Gentili

Posted on


do you prefer Makefile or package.json


As developer I need a tool to run some tasks programmatically. Since I have the memory of a goldfish, I always used Makefile, thus each task is written inside a target.


With autocomplete Makefiles helped me in digitations and in memory issues. In those cases tab is a good friend whenever I was in a terminal. I can type make and then press tab. Autocomplete show all targets available and this can make the job very easy.

Node.js projects

In Node.js project we have a package.json. I never used autocompletion in those cases. The nice part of Node.js projects, in this kind of context, is that we already have a package.json file and no other stuffs are needed.

Replace Makefiles with package.json

Because of I am developing Node.js exercices for some youtube videos, .. I am moving all the things I always had in Makefile, .. inside package.json scripts.

package.json example

    "name": "youtube-poliglotta",
    "version": "1.0.0",
    "dependencies": {
        "@fastify/mongodb": "5.0.0",
        "fastify": "4.11.0"
    "scripts": {
        "start": "node server.js",
        "start-mongo": "docker run -d  --name my-mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo",
        "stop-mongo": "docker stop my-mongo"
Enter fullscreen mode Exit fullscreen mode

In this case: npm run start-mongo help me to run, for example, mongo container.

The same with Makefile

    docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

In this case we have simple configuration.

Conclusion, pros, cons, ...

Both instruments are good. I love Makefile mainly for the autocomplete feature. This issue can be solved with this npm package for example. With Makefile we have separate file for tasks. Both are good to store somewhere tasks and avoid some documentation to remember how things should be done. I've seen most developer use package.json to add some tasks. In the manner you can see in examples. Makefile sometimes is not known. Package works both with Windows and *nix system.

So, .. what's your point of view? Are there other alternatives you use to run tasks? Please leave a comment.

Top comments (1)

maxart2501 profile image
Massimo Artizzu

You know me, but I'm a JS guy... So I'm biased 😜