7

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!

Nathan
  • 7,853
  • 4
  • 27
  • 50
nCardot
  • 5,992
  • 6
  • 47
  • 83
  • Possible duplicate of [What is the purpose of .bin folder in node\_modules?](https://stackoverflow.com/questions/25306168/what-is-the-purpose-of-bin-folder-in-node-modules) – João Pimentel Ferreira Jul 19 '19 at 13:46
  • 2
    Joao, I referred to an answer to that question in this question, and I asked because that information was missing from answers to that question. I know it contains binaries but I wanted to know what binaries are. – nCardot Jul 19 '19 at 16:57

2 Answers2

8

Binary or executable files are files which have already been compiled for your specific computer architecture and, once installed, these files can be ran 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 understood by your computer's underlying processor.

Hopefully that helps!

Nathan
  • 7,853
  • 4
  • 27
  • 50
2

According to npm docmentation

When in global mode, executables are linked into {prefix}/bin on Unix, or directly into {prefix} on Windows.

When in local mode, executables are linked into ./node_modules/.bin so that they can be made available to scripts run through npm. (For example, so that a test runner will be in the path when you run npm test.)

Binaries are executable files ( the compiled version of your file for a specific computer architecture) and once installed they can be run directly from your machine

Deeksha Sharma
  • 3,199
  • 1
  • 19
  • 16