espocrm / ext-template

Template repository for EspoCRM extensions
Creative Commons Zero v1.0 Universal
30 stars 17 forks source link

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

Closed bandtank closed 2 months ago

bandtank commented 2 months ago

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
bandtank commented 2 months ago

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