diff --git a/lib/internal/fs/rimraf.js b/lib/internal/fs/rimraf.js index 967ca6600a3274..6ddf956896a42f 100644 --- a/lib/internal/fs/rimraf.js +++ b/lib/internal/fs/rimraf.js @@ -7,7 +7,6 @@ 'use strict'; const { - ArrayPrototypeForEach, Promise, SafeSet, } = primordials; @@ -139,8 +138,10 @@ function _rmchildren(path, options, callback) { let done = false; - ArrayPrototypeForEach(files, (child) => { - const childPath = Buffer.concat([pathBuf, separator, child]); + const childPathPrefix = Buffer.concat([pathBuf, separator]); + + for (let i = 0; i < files.length; i++) { + const childPath = Buffer.concat([childPathPrefix, files[i]]); rimraf(childPath, options, (err) => { if (done) @@ -155,7 +156,7 @@ function _rmchildren(path, options, callback) { if (numFiles === 0) rmdir(path, callback); }); - }); + } }); }