Skip to main content

Getting started with Blockly

3. Add Blockly libraries

To start, you'll need to add Blockly dependencies to your app.

Blockly releases are published on npm regularly. There are multiple ways to use Blockly in your project, but for this codelab you will be installing Blockly with npm.

Install dependencies and run your app

For this codelab, you'll use npm to run your app. Use the following instructions

  1. Install node.js and npm if you haven't already.
  2. Navigate to the starter code folder packages/docs/docs/codelabs/getting-started/starter-code/ in your terminal.
  3. Run npm install in your terminal. npm install will install the necessary dependencies that are defined in package.json, including Blockly.
  4. Run npm start in your terminal.

After following these steps, a browser page should open automatically, or you can copy-paste the address that includes localhost into your browser. The page should be blank. Don't worry, we'll add in our Blockly workspace in the following steps.

Alternate imports

There are many ways to import a library in JavaScript, and this tutorial does not cover all of them. For samples that show how to integrate Blockly in your project, look at the examples folder in blockly-samples.