StartpodDocs

Install packages

Run npm install inside Startpod and understand cold and warm installs.

Startpod installs public npm packages directly into the pod's virtual filesystem. Package installation is enabled by default.

const install = await startpod.spawn("npm", ["install"])

install.output.pipeTo(
  new WritableStream({
    write(chunk) {
      console.log(chunk)
    },
  })
)

const exitCode = await install.exit
if (exitCode !== 0) throw new Error(`npm install exited with ${exitCode}`)

Startpod reads the mounted package.json, fetches packages from npm, verifies their integrity, and writes node_modules into the virtual filesystem.

Repeat installs

Startpod caches a compatible installed dependency tree in IndexedDB. A later install with the same lockfile can restore that tree without downloading every package again.

Listen for install-diagnostics when your interface needs to distinguish a warm cache hit from a cold install:

startpod.on("install-diagnostics", ({ warmStart }) => {
  console.log(warmStart ? "Restored dependencies" : "Installed dependencies")
})

Registry access

The default registry is npm. Authenticated and private-registry workflows are not a broad compatibility promise yet. See limitations.

On this page