2018. február 20., kedd

Micro:bit - self hosting

If you want to use the Microsoft MakeCode for programming your micro:bit you can use the online editor hosted by microbit.org:
https://makecode.microbit.org/#
Actually it has some drawbacks:
The site has no login. So you don't have your own environment online.
It store your projects on your computer (but actually I don't know where - I didn't find documentation on i). I'm working on my projects on three different computers. This makes virtually impossible to transfer or put into secure place (git server) my projects.
There are situations when you want to work on your things when disconnected from the internet.
Anyhow. It is possible to run the environment on your own computer:

  1. Install NodeJS. You can download it from here: https://nodejs.org/en/
    The current LTS version is sufficient
  2. Create a folder on your computer to store your projects, for example c:\microbit
  3. Open a command prompt and execute the following commands:
    npm install -g pxt
    npm install

    Close the command prompt (necessary for the environment variables just created)
  4. Open a command prompt and navigate to your folder:
    c:
    cd microbit
  5. Execute the  following command:
    pxt target microbit
Now your environment is ready. You can start it with tho following command:
pxt serve
Next time when you want to run it, this is the only command needed.
When it starts you can realize two things:

  • The command prompt you'll see a continuously rolling error message:
    "Error: ENOENT: no such file or directory, open 'C:\microbit\node_modules\pxt-microbit\targetconfig.json'"
  • There are no installable package in the "add packages" list just the integrated ones:

This means, you can't add any add-on.
The missing file is the descriptor of the add-on packages. You can download a template from here:
https://github.com/Microsoft/pxt-microbit/blob/master/targetconfig.json
So, if you stop the server (Ctrl-C), download this file into the folder mentioned in the error message, than restart the server (pxt serve). The error message will disappear and you can see the add-ons:


This file also can be used to add our own add-ons if we find something on the internet and want to add to our environment.

Nincsenek megjegyzések:

Megjegyzés küldése