2
votes

I am receiving the following error using fs-extra:

ERROR { [Error: EPERM: operation not permitted, unlink 'C:\Projects\xxx\branches\xxx\release'] errno: -4048, code: 'EPERM', syscall: 'unlink', path: 'C:\Projects\xxx\branches\xxx\release' }

When using this code in my node application:

const fse = require('fs-extra');
fse.copySync('../util/various/a.html', '../release');
fse.copySync('../util/various/b.html', '../release');

I would like to know, what could cause the error and how to fix it.

2

2 Answers

3
votes

fs-extra doesn't support copying a file to a directory.

This will work:

const fse = require('fs-extra');
fse.copySync('../util/various/a.html', '../release/a.html');
fse.copySync('../util/various/b.html', '../release/b.html');

This is as-designed (https://github.com/jprichardson/node-fs-extra/issues/320) although I am here because I ran into the same issue.

-2
votes

The module can't remove the destination file because of file's permissions (read-only).