A web-based JavaScript playground that lets you write and execute JavaScript code in both ES Modules and CommonJS formats.
- π 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
- Node.js (v18 or higher)
- npm or yarn
- Git
- Clone the repository:
git clone https://github.com/nadimtuhin/free-runjs.git
cd free-runjs
- Install dependencies:
npm install
# or
yarn install
- Create required directories:
mkdir -p temp/cjs temp/esm
- 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
- Run the development server:
npm run dev
# or
yarn dev
- Open http://localhost:3000 in your browser.
- Build the application:
npm run build
# or
yarn build
- Start the production server:
npm start
# or
yarn start
-
Write Code: Choose between ES Modules or CommonJS syntax and write your JavaScript code in the editor.
-
Install Packages: Click the "Packages" button to install npm packages. Type the package name and click "Install" or press Enter.
-
Run Code: Click the "Run" button or press Ctrl+Enter (Cmd+Enter on Mac) to execute your code.
-
Share Code: Your code is automatically saved in the URL, making it easy to share with others.
.
βββ 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
- Next.js - React Framework
- Monaco Editor - Code Editor
- Tailwind CSS - Styling
- Node.js - Runtime Environment
-
Missing temp directory: If you see errors about missing directories, make sure you've created the temp directories as mentioned in the installation steps.
-
Node.js version: Make sure you're using Node.js v18 or higher. You can check your version with:
node --version
- Port already in use: If port 3000 is already in use, you can use a different port:
PORT=3001 npm run dev
This project is licensed under the MIT License - see the LICENSE file for details.