Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is this npm switch fixing Windows path length issues

Tags:

node.js

npm

On Windows NPM has issues due to its deep nesting of dependencies. In order to fix this a friend suggested the following command

npm install <dep> -g --no-bin-link

The man pages say about this command

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

Could anyone explain, in plain language, what the impact this flag has on allowing dependencies to be installed that would usually causing deep path issues?

like image 835
McDonnellDean Avatar asked Nov 01 '22 20:11

McDonnellDean


1 Answers

Could anyone explain, in plain language, what the impact this flag has on allowing dependencies to be installed that would usually causing deep path issues?

Sure. Many packages published on npm can be used both as a command-line tool and programmatically. For example the jslint package publishes both a command-line tool for linting files and an API that can be required, so you can write code that uses jslint

The deep path issues usually become visible when creating the files that go into the bin directory, for command-line use. The deep paths usually do not affect packages used programmatically with require.

So for "regular" dependencies of a package, it is usually harmless to omit the bin links, because those dependencies are consumed with require.

For "dev" dependencies or packages installed globally, it is usually necessary to keep the bin links, because those packages are more likely to be used as command-line tools.

Incidentally you should update to the latest npm if you haven't yet -- latest is 2.1.16 at this writing, and a guide for updating npm on windows is here: https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows

like image 51
Sam Mikes Avatar answered Nov 12 '22 12:11

Sam Mikes