Skip to main content

Getting started with Blockly

3. Add Blockly libraries​

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

Install dependencies and run your app​

Use the following instructions to install dependencies and start the app:

  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, you'll add in your 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.