Published on

ncc CLI - Compile a Node.js project into a single file

Authors

There are cases in which we might want to bundle an entire Node.js project into a single file for example, when using a Node.js dependency in GitHub Action.

That's where ncc comes in.

You can think of this gcc for Node.js

It bundles everything that is needed for a project into a single file.

A Quick Demo

Since it's available as an npx script we don't necessarily need to install anything if you've the latest Node.js installed in your machine.

Then just head over to the project that you want to bundle/compile. And run build command

# replace index.js with your entry file
npx ncc build index.js -o dist

That will bundle everything (along with the dependency) for you.

You can read more about it in their GitHub repo

Happy bundling files!