espocrm/ext-template

Building the extension fails due to missing parent folders for build/assets/lib

Closed this issue · 1 comments

Here are the steps:

$ git clone git@github.com:espocrm/ext-template.git
$ cd ext-template
$ nvm use 22.2.0
$ php init.php      # All details entered as usual
$ npm install       # No issues
$ node build --all  # No issues

At this point, I tried to build the extension, but it failed:

$ node build --extension
Building extension package...
  Transpiling...
  Chunk 'init' done, 0 files.
  Chunk 'module-test' done, 0 files.
node:fs:1374
  const result = binding.mkdir(
                         ^

Error: ENOENT: no such file or directory, mkdir 'build/assets/lib'
    at Object.mkdirSync (node:fs:1374:26)
    at file:///Users/anthony.andriano/Repositories/ext-template/node_modules/espo-extension-tools/build.js:484:20 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: 'build/assets/lib'
}

Node.js v22.2.0

The issue happens here:
https://github.com/espocrm/extension-tools/blob/5ce0cf2e23e60c914f4d6a37ac4415d6da05c938/build.js#L483-L485

Changing the mkdirSync line to the following fixes the issue:

fs.mkdirSync('build/assets/lib', {recursive: true});
$ node build --extension
Building extension package...
  Transpiling...
  Chunk 'init' done, 0 files.
  Chunk 'module-test' done, 0 files.
  0 templates bundled in build/assets/lib/templates.tpl.
Package has been built.
Done

The PR was merged into the extension-tools repository. The issue is resolved.