Creating .asar from files throws error

I’m clueless why asar.createPackageFromFiles() keeps throwing an error.

Minimum Viable Example:

import { createPackageFromFiles } from 'asar';

const src = '/Users/idleberg/test';
const dest = '/Users/idleberg/test.asar';
const filenames = ["README.md", "package.json"];

try {
    await createPackageFromFiles(src, dest, filenames);
  } catch (error) {
    console.error(error);
  }

To my understanding, all parameters are passed as required, but it keeps throwing this error:

Error: ENOENT: no such file or directory, lstat 'README.md'

All files are present in src, so I have no clue why this wouldn’t work.

I’ve found the answer: contrary to the description of createPackageFromFiles(), the file argument does not take a path relative to the first argument. It only takes absolute paths :unamused:

1 Like