CodeSandbox CLI
raw JSON → 2.2.3 verified Sat Apr 25 auth: no javascript maintenance
Command-line interface (CLI) for uploading and deploying projects to CodeSandbox, an online code editor tailored for web applications. As of version 2.2.3, this tool allows developers to quickly upload local projects as templates or sandboxes using a single command. It requires authentication to prevent abuse. The library is relatively simple, with no major competitors in the same niche; it is maintained as part of the CodeSandbox ecosystem. Release cadence is low, with the last release in May 2020.
Common errors
error Error: You must be signed in first. Run codesandbox login. ↓
cause Attempting to deploy without authentication.
fix
Run 'codesandbox login' and authenticate via the browser.
error ERROR: Could not find package.json in the specified directory ↓
cause The CLI requires a package.json to determine the project type.
fix
Run the command from a directory containing a package.json, or specify a path that contains one.
error Error: Request failed with status code 401 ↓
cause Authentication token is invalid or expired.
fix
Re-authenticate by running 'codesandbox login' again.
Warnings
gotcha You must be signed in to CodeSandbox to use the CLI; otherwise deployment will fail. ↓
fix Run 'codesandbox login' first or authenticate interactively when prompted.
gotcha The CLI may not work with all project structures; it expects a package.json and supported files. ↓
fix Ensure your project has a valid package.json and is a standard web project (e.g., React, Vue, etc.).
deprecated The CLI uses the CodeSandbox v1 API which may be deprecated in favor of a newer API. ↓
fix Check CodeSandbox documentation for API updates; consider using the official web interface instead.
Install
npm install codesandbox yarn add codesandbox pnpm add codesandbox Imports
- CLI wrong
require('codesandbox')correctnpx codesandbox <path> - deploy wrong
codesandbox --upload ./pathcorrectcodesandbox ./path
Quickstart
# Install globally
npm install -g codesandbox
# Go to project directory
cd /my/project
# Deploy (will prompt for authentication if not logged in)
codesandbox ./
# Or with npx (no install required)
npx codesandbox ./my-project --output=url