Member-only story

How many levels of nested subfolders can be in a JavaScript project

Marian C.
3 min readOct 16, 2021

--

Let’s figure it out by exploring the source code of major Node.js-based projects

It is convenient to organize code into a logical hierarchy of nested folders. A bigger task often can be decomposed into several nested smaller subtasks. The smallest discrete subtasks can be encoded in individual modules. Highly specialized tiny modules are easier to test and thus to develop and finalize.

I this post I used interchangeably terms package and project. I my understanding, every package is someone’s project. Project is code under development that to be executed with Node.js has the standard format of Node.js packages. According to the Node.js documentation a package is a folder tree described by a package.json file. The package consists of the folder containing the package.json file and all subfolders until the next folder with package.json.

For Node.js-based JavaScript projects, there are no strict official recommendations on the optimal layout and the depth of a project folder tree. But in the Internet you can come across a belief that limited possibilities of module specifiers are incompatible with the deep hierarchies of folders.

To figure out the reasonable limits for folder hierarchy depth, I explored the code of prominent Node.js-based command line…

--

--

Marian C.
Marian C.

Written by Marian C.

Java, JavaScript and SQL developer. Interested in data collection and visualization.

No responses yet