Run code

In a JavaScript or web project, the preview runs your code by itself: each change rebuilds it, and the console shows what the code prints. In a Python, C, C++, Go or SQL project, you run the code with Run.

On this page

Do it yourself

#
  1. Open the project. The preview builds as soon as it opens, unless you turned off Run on opening.
  2. Edit a file. The preview rebuilds when you stop typing, after the Live view delay: 0.1 seconds unless you change it.
  3. To build it again by hand, choose the Reload button in the preview's toolbar, or press Ctrl+R (Control+R on a Mac).
  4. To stop the preview, choose the Stop button. To start it again, choose the Start Preview button. Stopping clears the build, so the next start builds everything again.
  5. To run one file instead of index.html, point at the file's icon in the file list: the icon turns into a play button. Click it.
  6. In a Python, C, C++, Go or SQL project, choose Run in the console's toolbar, or press Ctrl+R. The output appears in the editor.

To start over from nothing, press Ctrl+Shift+R (Control+Shift+R on a Mac): the build is cleared and runs again.

If it doesn't work

#

"No entry point found. Create index.html or click a file to run."

#

The preview starts from index.html. Without it, it tries index, main, script, src/main and src/script, with a script ending like .js, .ts, .jsx or .tsx. Create index.html, or choose a file under "Available files to run:".

"Entry point not found: /about"

#

The preview's address names a file that does not exist. For /about, the preview tries about, about.html and about/index.html. Choose one of the files the message lists.

"SPA mode is enabled but /index.html not found."

#

Create index.html, or turn off SPA mode. See SPA mode.

"Potential infinite loop: exceeded 1500 iterations."

#

Loop protection stopped a loop that ran more than 1,500 times. If your loop is meant to run longer, like a game loop or a long list, choose Disable Loop Protection in the console. Loop protection works only in the preview, never on the published site.

"Imported module ... is not installed."

#

The preview shows Missing Module. Choose Install followed by the package's name. See Add npm packages.

The preview does not change when you type

#

Live reload is off. Choose Reload, or turn it on again: see Turn off automatic runs.

The preview is blank, stuck or frozen

#

Press Ctrl+Shift+R, or choose Stop, then Start Preview. For more fixes, see The preview does not load.

Limits

#
  • The code runs in your browser. Code that needs a server, files on a disk or Node.js runs in a Cloud app instead: see Browser and Cloud projects.
  • Loop protection stops for, while and do loops, not a recursion that never ends.
  • The shortcuts work in the editor only. Help, Keyboard Shortcuts lists the others.