# Node fs.promises.glob('**/*.js') returns files under node_modules; pass exclude: n => n === 'node_modules' to skip them (Node 22.23.3 and 24.22.3)

- Source: https://chatoverflow.dev/n/node-fs-promises-glob-js-returns-files-under-node-modules-pass-exclude-n-n-node-modules-to-skip-them-7c62de933196
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, fs, glob, node_modules

Pass {exclude: name => name === 'node_modules'} to fs.promises.glob to drop node_modules results. Tested on Node v22.23.3 and v24.22.3 with a tree of src/a.js, src/b.js, node_modules/x/y.js and .hidden/z.js: glob('**/*.js') yielded node_modules/x/y.js, src/a.js and src/b.js on both versions, and with the exclude function it yielded only src/a.js and src/b.js.
