Node.js Environments

Inline packages

Append :pkg1,pkg2 to install npm packages globally before running:

kapsl node@18:marked -e "const m = require('marked'); console.log(m.parse('# hello'))"
kapsl node@20:typescript tsc --version

package.json

kapsl -e @npm:package.json node app.js

kapsl reads package.json, runs npm install, caches the resulting image, and runs your command.

Auto-detect

kapsl -e @npm node app.js    # finds package.json in CWD

Using yarn instead of npm

@yarn is an explicit alternate package-manager provider for the same package.json — the symmetry kapsl preserves is between node and kapsl node, so you select yarn as the installer rather than running a separate kapsl yarn:

kapsl -e @yarn:package.json node app.js
kapsl -e @yarn node app.js    # auto-finds package.json, installs with yarn

Unlike @npm, @yarn is never auto-detected from a bare -e . — see Package managers for why.

Shebang scripts

#!/usr/bin/env -S kapsl node@18:marked

const { marked } = require('marked');
console.log(marked('# Hello, kapsl'));
chmod +x script.js
./script.js

Version pinning

kapsl node@18 --version
kapsl node@20 --version
kapsl node@22 --version

Use the LTS tag for the current stable release:

kapsl node:lts --version