Installation
This guide covers the installation process for Sentinel Guard across different package managers and environments.
System Requirements
Before installing Sentinel Guard, ensure your system meets these requirements:
- Node.js: Version 16.0.0 or higher
- TypeScript: Version 5.0.0 or higher (for TypeScript projects)
- Package Manager: npm, yarn, pnpm, or bun
You can verify your Node.js version by running:
node --version
Package Manager Installation
Sentinel Guard is available on npm and compatible with all major package managers.
npm
npm install @uptimebeacon/sentinel-guard
yarn
yarn add @uptimebeacon/sentinel-guard
pnpm
pnpm add @uptimebeacon/sentinel-guard
bun
bun add @uptimebeacon/sentinel-guard
Development Dependencies
For TypeScript projects, you may also want to install type definitions for Node.js:
npm install --save-dev @types/node
Environment Setup
After installation, set up your environment variables. Create a .env
file in your project root:
SENTINEL_API_KEY=your-api-key-here
SENTINEL_API_URL=https://api.uptimebeacon.cloud
SENTINEL_MONITOR_API_KEY=your-monitor-api-key-here
Verification
Verify your installation by creating a simple test file:
import { SentinelGuard } from "@uptimebeacon/sentinel-guard";
console.log("Sentinel Guard imported successfully");
// Create an instance to verify configuration
const sentinel = new SentinelGuard({
apiKey: "test-key",
baseUrl: "https://api.example.com",
monitorApiKey: "test-monitor-key",
});
console.log("Sentinel Guard instance created");
Run the test file:
npx ts-node test-installation.ts
If you see both success messages, the installation is complete.
TypeScript Configuration
For TypeScript projects, ensure your tsconfig.json
includes proper module resolution:
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
CommonJS Projects
For CommonJS projects, use require syntax:
const { SentinelGuard } = require("@uptimebeacon/sentinel-guard");
const sentinel = new SentinelGuard({
apiKey: process.env.SENTINEL_API_KEY,
baseUrl: process.env.SENTINEL_API_URL,
monitorApiKey: process.env.SENTINEL_MONITOR_API_KEY,
});
Docker Installation
For containerized applications, add Sentinel Guard to your Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
# Your application setup here
Installation Issues
Common Problems
Module Not Found Error
If you encounter module resolution issues:
npm install --force
TypeScript Compilation Errors
Ensure you have the correct TypeScript version:
npm install --save-dev typescript@^5.0.0
Permission Errors
On Unix systems, you may need to use sudo or configure npm properly:
sudo npm install -g npm
Or configure npm to use a different directory:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Version Conflicts
If you encounter peer dependency warnings:
npm install --legacy-peer-deps
Node.js Version Issues
If you’re using an older Node.js version, consider using a version manager:
nvm (Node Version Manager)
nvm install 18
nvm use 18
n (Node.js version manager)
npm install -g n
n latest
Monorepo Installation
For monorepo setups with tools like Lerna or Nx:
# Install in workspace root
npm install @uptimebeacon/sentinel-guard --workspace=my-service
# Or install in specific package
cd packages/my-service
npm install @uptimebeacon/sentinel-guard
Bundler Configuration
Webpack
If using Webpack, ensure proper module resolution:
module.exports = {
resolve: {
extensions: [".ts", ".js"],
},
// other config
};
Vite
For Vite projects, no additional configuration is typically needed.
Rollup
For Rollup bundling:
import { nodeResolve } from "@rollup/plugin-node-resolve";
export default {
plugins: [nodeResolve()],
// other config
};