monotonic-pi-extensions/scoped-packages.md

77 lines
1.8 KiB
Markdown

# Scoped Packages
## Step 1: Create the npm org
```bash
npm org create mostalive
```
This creates the `@mostalive` scope on npm. You'll need to pay the [org fee](https://docs.npmjs.com/about-organizations) (currently ~$7/month for the basic tier).
Alternatively, if you already have an account, you can use your username directly — scoped packages can use your personal account too:
```bash
# No separate org creation needed if @mostalive is your npm username
```
Check if the scope exists:
```bash
npm org list
```
## Step 2: Rename the package
In `packages/pi-turn-limit/package.json`:
```json
{
"name": "@mostalive/pi-turn-limit",
"version": "0.1.0",
...
}
```
## Step 3: Publish
```bash
cd packages/pi-turn-limit
npm publish
```
Scoped packages require `--access public` on first publish (since npm defaults scoped packages to private):
```bash
npm publish --access public
```
## Step 4: Users install
```bash
pi install npm:@mostalive/pi-turn-limit
```
---
## Cheaper Alternative: Scoped Git Package
If you don't want to pay for an npm org, you can ship via git without scoping:
```bash
pi install git:github.com/mostalive/pi-turn-limit
```
No npm org needed. Users install directly from your GitHub repo. You'd still need to publish to npm for the `npm:` install path, but the git path is free.
---
## Summary
| Approach | Cost | User installs via |
|----------|------|-------------------|
| `npm org create` + scoped npm | ~$7/mo | `pi install npm:@mostalive/pi-turn-limit` |
| GitHub repo (no scope) | Free | `pi install git:github.com/user/repo` |
| Unscoped npm (`pi-turn-limit`) | Free | `pi install npm:pi-turn-limit` |
If you already have a personal npm account named `mostalive`, the scope is free — scoped packages just use your existing account. The org fee only applies if you create a separate organization entity.