Skip to content

Installation

Requirements

Node-APK requires Node.js 20 or later. This is because we use modern JavaScript features:

  • ESM (ECMAScript Modules)
  • async/await
  • ES2022 language features

WARNING

Node-APK is an ESM-only package. CommonJS is not supported.

Package Managers

bash
npm install node-apk
bash
yarn add node-apk
bash
pnpm add node-apk

Package.json Configuration

Since Node-APK is ESM-only, your project must support ESM. Add "type": "module" to your package.json:

json
{
  "name": "my-project",
  "type": "module",
  "dependencies": {
    "node-apk": "^2.0.0"
  }
}

TypeScript Configuration

For TypeScript projects, ensure your tsconfig.json supports ESM:

json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "esModuleInterop": true,
    "strict": true
  }
}

Verify Installation

Create a test file to verify the installation:

typescript
// test.mts
import { Apk } from "node-apk";

console.log("Node-APK installed successfully!");
console.log("Available exports:", Object.keys(await import("node-apk")));

Run it:

bash
node test.mts

You should see:

Node-APK installed successfully!
Available exports: [
  'Apk',
  'Certificate',
  'Manifest',
  'Receiver',
  'Locale',
  'Resource',
  'Resources',
  'XmlElement',
  'Source',
  'ZipEntry',
  'BufferLoader',
  'Chunk',
  'ChunkType',
  'StringPool',
  'parseResourceValue',
  'ResourceValue'
]

Common Issues

ERR_REQUIRE_ESM

If you see this error:

Error [ERR_REQUIRE_ESM]: require() of ES Module not supported

Solution: Your project is using CommonJS. Switch to ESM by:

  1. Adding "type": "module" to your package.json
  2. Changing .js files to .mjs or using ESM syntax

Cannot find module 'node-apk'

Solution: Make sure you've installed the package:

bash
npm install node-apk

Syntax Error: Cannot use import statement

Solution: Your Node.js version may be too old. Upgrade to Node.js 20+:

bash
node --version  # Should be 20.x or higher

Dependencies

Node-APK has minimal dependencies:

PackagePurpose
node-forgeCryptographic operations for certificates

There are no native dependencies, making it compatible with all platforms.

Next Steps

Released under the MIT License.