canirequire › CommonJS › 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.
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.
| Runtime | require("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).
| Versions | Format | First published |
|---|---|---|
| 15.0.1 – 22.1.1 | CommonJS | Nov 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
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- proxyquire 2.1.3CommonJS
- @stencil/core 4.44.2Dual
- enzyme 3.11.0CommonJS
- install 0.13.0CommonJS
- html-loader 5.1.0CommonJS
- grunt-cli 1.5.0CommonJS
- fs 0.0.1-securityCommonJS
- babel-plugin-transform-async-to-generator 6.24.1CommonJS