Error trying to run local pxt server

Hey, I am trying to run a local version of makecode as described in the tutorial (https://github.com/microsoft/pxt-maker).

I cloned the three mentioned gits, ran npm and build as in the tutorial and finished the setup. Since I did not make any changes and just wanted to try to run makecode locally I skipped the parts ‘Refresh dal.d.ts files’ and ‘CODAL changes’ and directly did the step Running by executing pxt serve

But uppon trying the command pxt serve it always throws the error I attached in the error log. It seems as if it has mainly two problems: First of all it cannot resolve the expression 'game‘ in playable.ts and second of all it says that the property ‘percentChance’ does not exist on type ‘typeof Math’.

This finally leads to the error 'Build failed: target build failed: Compiler test failed

Error: Compiler test failed

at Object.userError …’

It opened a new tab in my explorer but it only showed the makecode logo and did not move on.

Afterwards I tried to fix the problem by following the step ‘Refresh dal.d.ts files’ oft he tutorial. This ended with: ‘error: sim/tsconfig.json expected compilerOptions.outFile:“…/built/sim.js”, got “undefined”’ but besides that it seemed to work.

Then I again tried pxt serve and I got the same error, except that this time it seemed to start the local server since I could open a new project.

I am still a little bit worried about the last error that said that the Build failed. What does that error mean and is it critical for the following steps of adding a new custom board?

Thanks in advance

Saskia

Errorlog:

C:\Users\MyPath\makecode\pxt-maker>pxt serve
Using target maker with build engine codal
target: v C:\Users\MyPath\makecode\pxt-maker
pxt-core: v C:\Users\MyPath\makecode\pxt
building C:\Users\MyPath\makecode\pxt-maker\node_modules\pxt-common-packages\sim…
[run] cd C:\Users\MyPath\makecode\pxt-maker\node_modules\pxt-common-packages\sim; node …/node_modules/typescript/bin/tsc
log strings: 24 files; 0 strings → sim-strings.json
copying common-sim…
C:/Users/MyPath/makecode/pxt-maker/node_modules/@types/node/index.d.ts(35,1): error TS1084: Invalid ‘reference’ directive syntax.
C:/Users/MyPath/makecode/pxt-maker/node_modules/@types/node/index.d.ts(43,30): error TS1005: ‘=’ expected.
C:/Users/MyPath/makecode/pxt-maker/node_modules/@types/node/index.d.ts(46,30): error TS1005: ‘=’ expected.
C:/Users/MyPath/makecode/pxt-maker/sim/dalboard.ts(174,87): error TS1109: Expression expected.
C:/Users/MyPath/makecode/pxt-maker/sim/dalboard.ts(174,93): error TS1109: Expression expected.
C:/Users/MyPath/makecode/pxt-maker/sim/dalboard.ts(174,126): error TS1005: ‘:’ expected.
building target.json in C:\Users\MyPath\makecode\pxt-maker…
building C:\Users\MyPath\makecode\pxt-maker\libs\base
building C:\Users\MyPath\makecode\pxt-maker\libs\base—light

building C:\Users\MyPath\makecode\pxt-maker\libs\game
building C:\Users\MyPath\makecode\pxt-maker\libs\game—light
building C:\Users\MyPath\makecode\pxt-maker\libs\mixer
playable.ts(36,9): error TS2304: Cannot find name ‘game’.

playable.ts(40,9): error TS2304: Cannot find name ‘game’.

soundEffect.ts(310,22): error TS2339: Property ‘percentChance’ does not exist on type ‘typeof Math’.

soundEffect.ts(320,67): error TS2339: Property ‘percentChance’ does not exist on type ‘typeof Math’.

building C:\Users\MyPath\makecode\pxt-maker\libs\mixer—none
playable.ts(36,9): error TS2304: Cannot find name ‘game’.

playable.ts(40,9): error TS2304: Cannot find name ‘game’.

soundEffect.ts(310,22): error TS2339: Property ‘percentChance’ does not exist on type ‘typeof Math’.

soundEffect.ts(320,67): error TS2339: Property ‘percentChance’ does not exist on type ‘typeof Math’.

… and many other similar errors

building C:\Users\MyPath\makecode\pxt-maker\libs\wifi—esp32
building C:\Users\MyPath\makecode\pxt-maker\libs\mqtt
building C:\Users\MyPath\makecode\pxt-maker\libs\azureiot
azureiot.ts(38,35): error TS2304: Cannot find name ‘crypto’.
building C:\Users\MyPath\makecode\pxt-maker\libs\settings
building C:\Users\MyPath\makecode\pxt-maker\libs\settings—esp32

… again some building and similar errors as those before

pxt_modules/mixer—samd/soundEffect.ts(320,67): error TS2339: Property ‘percentChance’ does not exist on type ‘typeof Math’.


*** Build failed: target build failed: Compiler test failed
Error: Compiler test failed
at Object.userError (C:\Users\MyPath\makecode\pxt\built\pxt.js:98791:25)
at C:\Users\MyPath\makecode\pxt\built\pxt.js:164148:19
at async C:\Users\MyPath\makecode\pxt\built\pxt.js:162696:19
at async C:\Users\MyPath\makecode\pxt\built\pxt.js:99398:42
at async Promise.all (index 0)
at async promisePoolAsync (C:\Users\MyPath\makecode\pxt\built\pxt.js:99404:21)
at async buildTargetCoreAsync (C:\Users\MyPath\makecode\pxt\built\pxt.js:162678:5)
at async buildTarget (C:\Users\MyPath\makecode\pxt\built\pxt.js:162943:13)
at async buildAndWatchTargetAsync (C:\Users\MyPath\makecode\pxt\built\pxt.js:162970:5)


Starting server in C:\Users\MyPath\makecode\pxt-maker
With pxt core at C:\Users\MyPath\makecode\pxt
starting local ws server at 3233…

To launch the editor, open this URL:
http://localhost:3232/#local_token=b76f132c-ad13-42b2-7388-1f607dec50b1&wsport=3233


opening http://localhost:3232/#local_token=b76f132c-ad13-42b2-7388-1f607dec50b1&wsport=3233

maker doesn’t currently work with the latest pxt-common-packages, you need version 10.1.1

cd pxt-common-packages
git checkout v10.1.1

Thanks for your advice, it solved most of the errors. The only error I have left is the one in the new Errorlog. Is this a critical error? It seems as if I can still start a local hosted session even though this error is thrown.

Errorlog:

C:\Users\MyPath\makecode\pxt-maker>pxt serve
Using target maker with build engine codal
target: v0.15.66 C:\Users\MyPath\makecode\pxt-maker
pxt-core: v9.1.1 C:\Users\MyPath\makecode\pxt
building C:\Users\MyPath\makecode\pxt-maker\node_modules\pxt-common-packages\sim…
[run] cd C:\Users\MyPath\makecode\pxt-maker\node_modules\pxt-common-packages\sim; node …/node_modules/typescript/bin/tsc
…/libs/mixer/sim/music.ts:3:58 - error TS2345: Argument of type ‘RefBuffer’ is not assignable to parameter of type ‘Uint8Array’.
Type ‘RefBuffer’ is missing the following properties from type ‘Uint8Array’: BYTES_PER_ELEMENT, buffer, byteLength, byteOffset, and 27 more.

3 return AudioContextManager.playInstructionsAsync(b)
~
Found 1 error in …/libs/mixer/sim/music.ts:3


*** Build failed: common sim build failed: Exit code: 2 from cd C:\Users\MyPath\makecode\pxt-maker\node_modules\pxt-common-packages\sim; node …/node_modules/typescript/bin/tsc
Error: Exit code: 2 from cd C:\Users\MyPath\makecode\pxt-maker\node_modules\pxt-common-packages\sim; node …/node_modules/typescript/bin/tsc
at ChildProcess. (C:\Users\MyPath\makecode\pxt\built\nodeutil.js:78:24)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5)


Starting server in C:\Users\MyPath\makecode\pxt-maker
With pxt core at C:\Users\MyPath\makecode\pxt
starting local ws server at 3233…

To launch the editor, open this URL:
http://localhost:3232/#local_token=b76f132c-ad13-42b2-7388-1f607dec50b1&wsport=3233


opening http://localhost:3232/#local_token=b76f132c-ad13-42b2-7388-1f607dec50b1&wsport=3233
offline HEX not found: C:\Users\MyPath\makecode\pxt-maker\built\hexcache\d01e6d77faa7450bdaa33e2c609e0fdedd76af3b34f5cefc09c387fd9c76add9.hex
ws connection at /b76f132c-ad13-42b2-7388-1f607dec50b1/hid
offline HEX not found: C:\Users\MyPath\makecode\pxt-maker\built\hexcache\1c9f7c3ccdda1c40617f9990d5dc907c922c0a4c639147d99f7c6a6df149eb95.hex

Hmmm… you might need to go back to an older version of pxt too. Looks like pxt-maker is currently on 8.1.1.

The local serve should work even with those errors, but if you make any changes to the sim then you might run into issues. Switching to the old pxt should fix them.

Out of curiosity, what are you trying to do with pxt-maker locally? If you’re just working on TypeScript projects and not blocks, you might have more luck using the makecode cli instead.

Thanks, I’ll see if it works.
I am trying to add a robot I designed to makecode by adding it as a new board. Therefore I need to try a few things locally :slight_smile: