Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

ncc

> 编程语言
Open source

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.

9.8K stars0 likes2 views
WebsiteGitHub

About

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.

ncc

Simple CLI for compiling a Node.js module into a single file, together with all its dependencies, gcc-style.

Motivation

  • Publish minimal packages to npm
  • Only ship relevant app code to serverless environments
  • Don't waste time configuring bundlers
  • Generally faster bootup time and less I/O overhead
  • Compiled language-like experience (e.g.: go)

Design goals

  • Zero configuration
  • TypeScript built-in
  • Only supports Node.js programs as input / output
  • Support all Node.js patterns and npm modules

Usage

Installation

bash
npm i -g @vercel/ncc

Usage

bash
$ ncc <cmd> <opts>

Eg:

bash
$ ncc build input.js -o dist

If building an .mjs or .js module inside a "type": "module" package boundary, an ES module output will be created automatically.

Outputs the Node.js compact build of input.js into dist/index.js.

Note: If the input file is using a .cjs extension, then so will the corresponding output file. This is useful for packages that want to use .js files as modules in native Node.js using a "type": "module" in the package.json file.

Commands:

  build <input-file> [opts]
  run <input-file> [opts]
  cache clean|dir|size
  help
  version

Options:

…

Execution Testing

For testing and debugging, a file can be built into a temporary directory and executed with full source maps support with the command:

bash
$ ncc run input.js

With TypeScript

The only requirement is to point ncc to .ts or .tsx files. A tsconfig.json file is necessary. Most likely you want to indicate es2015 support:

json
{
  "compilerOptions": {
    "target": "es2015",
    "moduleResolution": "node"
  }
}

If typescript is found in devDependencies, that version will be used.

Package Support

Some packages may need some extra options for ncc support in order to better work with the static analysis.

See package-support.md for some common packages and their usage with ncc.

Programmatically From Node.js

…

When watch: true is set, the build object is not a promise, but has the following signature:

javascript
{
  // handler re-run on each build completion
  // watch errors are reported on "err"
  handler (({ err, code, map, assets }) => { ... })
  // handler re-run on each rebuild start
  rebuild (() => {})
  // close the watcher
  void close ();
}

Caveats

  • Files / assets are relocated based on a static evaluator. Dynamic non-statically analyzable asset loads may not work out correctly

Issues· 222 open

View all issuesOpen on GitHub
  • #1212

    Build fails with `composite: true` in `tsconfig.json`

    bughelp wantedUpdated Jul 29, 2026
  • #1336

    Typescript 7 support

    help wantedUpdated Jul 26, 2026
  • #1322

    target esm instead of commonjs

    Updated May 29, 2026
  • #1169

    Are there multiple js files in the directory packaged by NCC?

    questionUpdated May 19, 2026
  • #1311

    github/core package fails build because of exports map

    bughelp wantedUpdated Apr 21, 2026
  • #935

    Leave dynamic import untouched.

    Updated Apr 19, 2026
  • #1264

    Error: Could not load TypeScript compiler with NPM package name

    Updated Apr 7, 2026
  • #1146

    Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.

    bugUpdated Feb 1, 2026
  • #1238

    TypeScript Declarations

    enhancementhelp wantedUpdated Dec 11, 2025
  • #1292

    ncc build generating multiple index.js files instead of a single bundle after upgrading Node.js

    Updated Nov 20, 2025

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言