canirequire

canirequireCommonJS › ng-packagr

Is ng-packagr ESM-only? Can you require() it?

Compile and package Angular libraries in Angular Package Format (APF)

Last verified Sep 9, 2026 against ng-packagr@22.1.1. JSON

CommonJS CommonJS — require() works on every Node.js version

ng-packagr ships CommonJS only. require("ng-packagr") works everywhere. import "ng-packagr" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Latest
22.1.1 (Aug 4, 2026)
Module format
CommonJS
Last CommonJS version
22.1.1
TypeScript types
Bundled
Node engines
^22.22.3 || ^24.15.0 || >=26.0.0
Weekly downloads
1.1M
License
MIT

Does ng-packagr@22.1.1 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("ng-packagr") from a CommonJS file and import "ng-packagr" from an ES module.

Runtimerequire("ng-packagr")import "ng-packagr"
Node.js 18✗ failsERR_REQUIRE_ESM✗ failsERR_REQUIRE_ESM
Node.js 20✓ works✓ works
Node.js 22✓ works✓ works
Node.js 24✓ works✓ works
Node.js 26✓ works✓ works
Bun 1.4✓ works✓ works

A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.

How to import ng-packagr

ES modules (import)

import ngPackagr from "ng-packagr";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

const ngPackagr = require("ng-packagr");

Module format by version

Derived from the type, main and exports fields of every stable release on npm (194 versions; the newest 60 shown).

VersionsFormatFirst published
15.0.1 – 22.1.1CommonJSNov 23, 2022

Frequently asked

Is ng-packagr ESM-only?

ng-packagr@22.1.1 is a CommonJS package. ng-packagr ships CommonJS only. require("ng-packagr") works everywhere. import "ng-packagr" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

Can I import ng-packagr with ES module syntax?

Yes. import ngPackagr from "ng-packagr" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

Does ng-packagr work in Bun?

Yes. import "ng-packagr" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does ng-packagr ship TypeScript types?

Yes. ng-packagr bundles its own type declarations; no @types package is needed.

Links

Other commonjs packages

Similar popularity