# Build error on a fresh Ubuntu 24.04

**URL:** https://forum.makecode.com/t/build-error-on-a-fresh-ubuntu-24-04/29775
**Category:** PXT
**Created:** [July 21, 2024, 7:40pm UTC](https://forum.makecode.com/t/build-error-on-a-fresh-ubuntu-24-04/29775 "2024-07-21T19:40:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ggsato](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ggsato/32/16238_2.png) [@ggsato](https://forum.makecode.com/u/ggsato)
#### Post date: [July 21, 2024, 7:40pm UTC](https://forum.makecode.com/t/build-error-on-a-fresh-ubuntu-24-04/29775/1 "2024-07-21T19:40:32Z")

</div>

Hello,

I am preparing a MakeCode and its variants locally on my Ubuntu 24.04 box in Japanese for my kids and their friends.

I have just followed [the Build instruction](https://github.com/microsoft/pxt?tab=readme-ov-file#build), but failed as follows.

```auto
~/projects/pxt$ node --version
v18.19.1
~/projects/pxt$ npm --version
9.2.0
~/projects/pxt$ npm install
...
Installing authcode...
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/tsato/projects/pxt/built/react-common/components/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/tsato/projects/pxt/built/react-common/components/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
...
~/projects/pxt$ grep react-common authcode/package.json 
    "react-common": "file:../built/react-common/components",

```

There is no such a folder called “built” at this point.

I checked the change history of `authcode/package.json`. But it has been 2 years since the last change. Is there any command I should do before running `npm install`?

---

<div class="post-metadata">

### Author: ![ggsato](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ggsato/32/16238_2.png) [@ggsato](https://forum.makecode.com/u/ggsato)
#### Post date: [July 25, 2024, 5:30am UTC](https://forum.makecode.com/t/build-error-on-a-fresh-ubuntu-24-04/29775/2 "2024-07-25T05:30:33Z")

</div>

Regardless of this specific issue, there is a chicken-egg situation here. `built` folder is referenced by a module to be installed. But `built` folder is created by `gulp`. Yet, `gulp` can not be run without running `npm install` first because it requires local modules.

So, here’s the procedure to build a bit ugly but successfully.

1. `pxt$ sudo npm install gulp`
2. `pxt$ npm install`
  - this will fail because of the same error as I reported because no `built` folder exists

3. `pxt$ git apply gulp_patch.diff`
  - see below for the detail

4. `pxt$ gulp`
  - this will build TypeScript files but fail becuase not enough modules exist, yet

5. `pxt$ npm install`
  - this will succeed

6. `pxt$ gulp`
  - this will suceed

7. `pxt$ gulp test`
  - only `karma` fails

The patch contains a code snippet that used to generate a dummy `package.json`, which was removed sometime ago. Also, `karma` is commented out.

> <https://github.com/microsoft/pxt/blob/2fdfed834acaf918436f3d8dcb23e3d9d8df4825/gulpfile.js#L53-L64>

```auto
pxt$ cat gulp_patch.diff 
diff --git a/gulpfile.js b/gulpfile.js
index 1abd2b131..071509759 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -50,6 +50,21 @@ const reactCommon = () => compileTsProject("react-common", "built/react-common",
 const pxtblocks = () => compileTsProject("pxtblocks", "built/pxtblocks", true);
 const pxtservices = () => compileTsProject("pxtservices", "built/pxtservices", true);
 
+// We output a dummy package.json in the built react-common directory to prevent
+// npm from complaining when we npm install in the skillmap and authcode
+const reactCommonPackageJson = () => {
+ fs.writeFileSync(path.resolve("built/react-common/components/package.json"), `
+ {
+ "name": "react-common",
+ "description": "",
+ "version": "0.0.0",
+ "dependencies": {},
+ "devDependencies": {}
+ }
+ `)
+ return Promise.resolve();
+}
+
 const pxtapp = () => gulp.src([
     "node_modules/lzma/src/lzma_worker-min.js",
     "node_modules/dompurify/dist/purify.min.js",
@@ -673,7 +688,7 @@ const testAll = gulp.series(
     testpytraces,
     testtutorials,
     testlanguageservice,
- karma,
+ //karma,
     testSkillmap,
     testpxteditor
 )
@@ -739,6 +754,7 @@ const buildAll = gulp.series(
     gulp.parallel(pxtjs, pxtdts, pxtapp, pxtworker, pxtembed),
     targetjs,
     reactCommon,
+ reactCommonPackageJson,
     gulp.parallel(buildcss, buildSVGIcons),
     maybeBuildWebapps(),
     webapp,

```
