Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install: when to use --no-bin-links?

When and why we should use the option --no-bin-links when we install npm packages?

The official docs say:

The --no-bin-links argument will prevent npm from creating symlinks for any binaries the package might contain.

But it is still unclear to me for which scenarios we have to specify this.

What will be the impact of the specifying of this option on the functionality of the package? Will the package when used error out?

like image 952
Vijey Avatar asked Aug 23 '16 10:08

Vijey


People also ask

What happens if you npm install without -- save?

Optional dependencies are those packages which are only used when a particular feature of the application is used and will not be required if that functionality isn't used. –no-save: When this command is used with npm install it will not allow the installed packages from being saved into the dependency section.

Does npm install require package json?

Creating a package. json file is typically the first step in a Node project, and you need one to install dependencies in npm. If you're starting a project from scratch, you create a package. json file to hold important metadata about your project and record your dependencies.

Does npm install install all dependencies?

By default, npm install will install all modules listed as dependencies in package. json . With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies .

Do I need save flag for npm?

You don't need --save anymore for NPM installs. This was long the golden standard to install a package and save it as a dependency in your project. Meaning if we didn't specify the --save flag, it would only get locally installed and not added to the package. json file.


2 Answers

One scenario that I can think of is working with a virtual machine (i.e. vagrant w/ virtual box or VMware) on windows host.
You can't translate symlinks to a synchronized folder on Windows share, so you will need this option to go around it.

Use it for any filesystem that doesn’t support symbolic links.

like image 194
Andy Theos Avatar answered Sep 20 '22 08:09

Andy Theos


So far one of the scenarios that I came across that --no-bin-links may help is when deploying packages in environments that may not have access to NPM Enterprise and you'd want to actually install all the packages and deploy the node_modules directly, in which case symlinks may cause some problem ( as you can't deploy them ), using this flag solve this problem.

like image 31
mim Avatar answered Sep 20 '22 08:09

mim