Skip to content

nadimtuhin/free-runjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RunJS - JavaScript Playground

A web-based JavaScript playground that lets you write and execute JavaScript code in both ES Modules and CommonJS formats.

Features

  • πŸ”„ Support for both ES Modules and CommonJS
  • πŸ“¦ Real-time package installation and management
  • πŸ“ Multiple file tabs support
  • πŸ’Ύ Auto-save to localStorage
  • πŸ”— Shareable URLs
  • 🎨 Modern dark theme UI
  • ⚑️ Instant code execution
  • πŸ“‹ Clean output display

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Git

Installation

  1. Clone the repository:
git clone https://github.com/nadimtuhin/free-runjs.git
cd free-runjs
  1. Install dependencies:
npm install
# or
yarn install
  1. Create required directories:
mkdir -p temp/cjs temp/esm
  1. Set up environment variables:
# Create a .env.local file with the following content
touch .env.local

Add the following to .env.local:

NEXT_PUBLIC_BASE_URL=http://localhost:3000
  1. Run the development server:
npm run dev
# or
yarn dev
  1. Open http://localhost:3000 in your browser.

Production Build

  1. Build the application:
npm run build
# or
yarn build
  1. Start the production server:
npm start
# or
yarn start

Usage

  1. Write Code: Choose between ES Modules or CommonJS syntax and write your JavaScript code in the editor.

  2. Install Packages: Click the "Packages" button to install npm packages. Type the package name and click "Install" or press Enter.

  3. Run Code: Click the "Run" button or press Ctrl+Enter (Cmd+Enter on Mac) to execute your code.

  4. Share Code: Your code is automatically saved in the URL, making it easy to share with others.

Project Structure

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/              # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ api/         # API routes
β”‚   β”‚   β”‚   └── execute/ # Code execution endpoints
β”‚   β”‚   └── page.tsx    # Main editor page
β”‚   └── styles/          # Global styles
β”œβ”€β”€ temp/                # Temporary directory for code execution
β”‚   β”œβ”€β”€ cjs/            # CommonJS modules
β”‚   └── esm/            # ES modules
└── public/             # Static files

Built With

Common Issues

  1. Missing temp directory: If you see errors about missing directories, make sure you've created the temp directories as mentioned in the installation steps.

  2. Node.js version: Make sure you're using Node.js v18 or higher. You can check your version with:

node --version
  1. Port already in use: If port 3000 is already in use, you can use a different port:
PORT=3001 npm run dev

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

πŸš€ A modern web-based JavaScript playground supporting ES Modules, CommonJS, real-time package installation, and code sharing

Topics

Resources

License

Stars

Watchers

Forks

Packages