---
title: "NPM Install"
description: "Detailed guide to installing the TraceRTM SDK with npm"
---

# NPM Install

Comprehensive guide to installing and managing the TraceRTM JavaScript SDK using npm.

## Basic Installation

```bash
npm install @tracertm/sdk
```

This installs the latest stable version of the SDK as a production dependency.

---

## Installation Options

### Save as Production Dependency

```bash
npm install @tracertm/sdk
# or explicitly
npm install @tracertm/sdk --save
```

This adds to `dependencies` in package.json:

```json
{
  "dependencies": {
    "@tracertm/sdk": "^2.0.0"
  }
}
```

### Save as Dev Dependency

For testing utilities or development-only usage:

```bash
npm install @tracertm/sdk --save-dev
```

### Install Specific Version

```bash
# Latest stable
npm install @tracertm/sdk@latest

# Specific version
npm install @tracertm/sdk@2.0.0

# Version range
npm install @tracertm/sdk@^2.0.0

# Beta/RC versions
npm install @tracertm/sdk@next
npm install @tracertm/sdk@beta
```

### Global Installation (CLI tools)

```bash
npm install -g @tracertm/sdk
```

---

## Version Pinning

### Exact Version

```bash
npm install @tracertm/sdk@2.0.0 --save-exact
```

Results in:

```json
{
  "dependencies": {
    "@tracertm/sdk": "2.0.0"
  }
}
```

### Version Ranges

| Syntax | Meaning |
|--------|---------|
| `2.0.0` | Exact version |
| `^2.0.0` | Compatible with 2.x.x (minor/patch updates) |
| `~2.0.0` | Approximately 2.0.x (patch updates only) |
| `>=2.0.0` | 2.0.0 or higher |
| `2.0.0 - 3.0.0` | Range from 2.0.0 to 3.0.0 |

---

## Lock Files

### package-lock.json

npm automatically creates and updates `package-lock.json`:

```bash
# Install from lock file (CI/production)
npm ci

# Update lock file
npm install
```

### Best Practices

1. **Always commit** `package-lock.json` to version control
2. **Use `npm ci`** in CI/CD pipelines for reproducible builds
3. **Review lock file changes** during code review

---

## Workspaces (Monorepos)

### Setup Workspaces

```json
// package.json (root)
{
  "name": "my-monorepo",
  "workspaces": ["packages/*", "apps/*"]
}
```

### Install in Specific Workspace

```bash
npm install @tracertm/sdk --workspace=packages/api
```

### Install in All Workspaces

```bash
npm install @tracertm/sdk --workspaces
```

---

## Peer Dependencies

The SDK has minimal peer dependencies:

```json
{
  "peerDependencies": {
    "typescript": ">=4.7.0"
  },
  "peerDependenciesMeta": {
    "typescript": {
      "optional": true
    }
  }
}
```

TypeScript is optional but recommended for the best development experience.

---

## Updating

### Check for Updates

```bash
npm outdated @tracertm/sdk
```

### Update to Latest

```bash
npm update @tracertm/sdk
```

### Update to Specific Version

```bash
npm install @tracertm/sdk@2.1.0
```

### Audit Security

```bash
npm audit

# Fix vulnerabilities
npm audit fix
```

---

## Uninstalling

```bash
npm uninstall @tracertm/sdk
```

---

## Offline Installation

### Pack for Offline Use

```bash
npm pack @tracertm/sdk
```

### Install from Tarball

```bash
npm install tracertm-sdk-2.0.0.tgz
```

---

## Troubleshooting

### Clear npm Cache

```bash
npm cache clean --force
```

### Delete node_modules and Reinstall

```bash
rm -rf node_modules package-lock.json
npm install
```

### Check npm Configuration

```bash
npm config list
```

### Registry Issues

```bash
# Check registry
npm config get registry

# Reset to default
npm config set registry https://registry.npmjs.org/
```

---

## npm Scripts

Add useful scripts to package.json:

```json
{
  "scripts": {
    "tracertm:test": "node -e \"const {TraceRTMClient} = require('@tracertm/sdk'); console.log('SDK loaded')\"",
    "tracertm:version": "npm list @tracertm/sdk"
  }
}
```

---

## Related Documentation

- [Installation Overview](/docs/api-reference/sdks/javascript/installation) - All installation methods
- [Yarn Install](/docs/api-reference/sdks/javascript/yarn-install) - Using yarn instead
- [Quickstart](/docs/api-reference/sdks/javascript/quickstart) - Get started quickly
