Installation
Complete installation guide for Agent-Pass across different environments and package managers.
Quick Install
Install with npmbash
npm install agent-passComplete Installation
For production use, install all recommended dependencies:
TypeScript Project Setupbash
# Install core package
npm install agent-pass
# Install TypeScript dependencies
npm install --save-dev typescript @types/node
# Install crypto polyfill for browser environments (optional)
npm install crypto-browserify
# Verify installation
npx tsc --versionEnvironment Setup
Node.js
Server-side applications
Requirements:
- Node.js 18.0.0 or higher
- npm 9.0.0 or higher
- Built-in crypto module
// No additional setup required
import { AgentPass } from 'agent-pass';
const agentPass = new AgentPass();Browser
Client-side applications
Requirements:
- Modern browser with WebCrypto
- Crypto polyfill
- Bundler configuration
// Install polyfill
npm install crypto-browserify
// Configure webpack/vite
module.exports = {
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify')
}
}
};Deno/Bun
Alternative runtimes
Status:
- Deno: Experimental support
- Bun: Full compatibility
- Edge functions: Limited
# Bun installation
bun add agent-pass
# Deno usage (experimental)
import { AgentPass } from "npm:agent-pass";TypeScript Configuration
Recommended TypeScript configuration for optimal compatibility:
tsconfig.jsonjson
{
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020", "DOM"],
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"types": ["node"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}Verify Installation
Test your installation with this simple verification script:
verify-installation.jsjavascript
import { AgentPass } from 'agent-pass';
async function verifyInstallation() {
try {
console.log('π Verifying Agent-Pass installation...');
// Test basic initialization
const agentPass = new AgentPass({
keyType: 'Ed25519',
didMethod: 'did:key'
});
console.log('β
AgentPass initialized successfully');
// Test agent creation
const agent = await agentPass.createAgent({
name: 'TestAgent',
version: '1.0.0',
capabilities: ['test:verify']
});
console.log('β
Agent created:', agent.did);
// Test basic signing
const testData = { message: 'Hello Agent-Pass!' };
const signature = await agent.sign(testData);
console.log('β
Signing works:', signature.length > 0);
console.log('π Installation verified successfully!');
console.log('π Ready to build with Agent-Pass');
} catch (error) {
console.error('β Installation verification failed:', error.message);
console.error('π‘ Please check the troubleshooting section');
}
}
verifyInstallation();Run verificationbash
# Save the script as verify-installation.js and run:
node verify-installation.js
# Or with Bun:
bun verify-installation.jsTroubleshooting
Module not found error: Make sure you're using Node.js 18+ and have installed the package correctly. Try deleting node_modules and reinstalling.
Crypto module error in browser: Install and configure crypto-browserify polyfill. Update your bundler configuration to include the fallback.
TypeScript compilation errors: Ensure your tsconfig.json target is ES2020 or higher. Install @types/node for Node.js type definitions.
ESM/CommonJS issues: Agent-Pass is published as ESM. Use import syntax and ensure your package.json has "type": "module" for Node.js projects.
Common Solutions
Clear package manager cache:
# npm
npm cache clean --force
# yarn
yarn cache clean
# pnpm
pnpm store pruneReinstall dependencies:
rm -rf node_modules package-lock.json
npm installCheck Node.js version:
node --version
# Should be 18.0.0 or higher