Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 959
nCardot Avatar asked Apr 09 '19 19:04

nCardot


2 Answers

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!

like image 71
Nathan Avatar answered Nov 03 '22 02:11

Nathan


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

like image 33
Deeksha Sharma Avatar answered Nov 03 '22 02:11

Deeksha Sharma