node.jsnpmnode-modulescpu-architecture

Purpose of the .bin directory within node_modules? What are binaries?


What's the purpose of the .bin directory within node_modules?

In another question, the answerer stated:

"it's where your binaries (executables) from your node modules are located."

So additionally can someone explain to me the following: What are binaries/executables?

Any help would be greatly appreciated!


Solution

  • Binary or executable files are files which have already been compiled for your specific computer architecture and, once installed, these files can be run directly on your computer. Common instruction set architectures are: X86 and ARM, which most computer processors are based upon. Contrary to binary files, source files are the actual source code itself and these files need to be compiled prior to installing.

    As for the .bin directory, within ./node_modules/.bin, this directory stores all the executables of your node_modules for which your project is dependent upon to run. This allows your project to just 'run' the libraries which are necessary, for your project, without you having to worry about compiling these files yourself. By compiling, I mean transforming the source code down to executable code (machine code) which can be understood by your computer's underlying processor.

    Hopefully that helps!