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-apkbash
yarn add node-apkbash
pnpm add node-apkPackage.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.mtsYou 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 supportedSolution: Your project is using CommonJS. Switch to ESM by:
- Adding
"type": "module"to yourpackage.json - Changing
.jsfiles to.mjsor using ESM syntax
Cannot find module 'node-apk'
Solution: Make sure you've installed the package:
bash
npm install node-apkSyntax 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 higherDependencies
Node-APK has minimal dependencies:
| Package | Purpose |
|---|---|
node-forge | Cryptographic operations for certificates |
There are no native dependencies, making it compatible with all platforms.
Next Steps
- Getting Started - Learn how to use Node-APK
- TypeScript - TypeScript-specific configuration