Skip to content

Commit 19762b4

Browse files
authored
docs: modify misleading doc about package.json:bin (#5529)
docs: modify Misleading doc about bins closes #3788
1 parent 8402fd8 commit 19762b4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

docs/content/configuring-npm/package-json.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,14 @@ install into the PATH. npm makes this pretty easy (in fact, it uses this
339339
feature to install the "npm" executable.)
340340

341341
To use this, supply a `bin` field in your package.json which is a map of
342-
command name to local file name. When this package is installed
343-
globally, that file will be linked where global bins go so it is
344-
available to run by name. When this package is installed as a
345-
dependency in another package, the file will be linked where it will be
346-
available to that package either directly by `npm exec` or by name in other
347-
scripts when invoking them via `npm run-script`.
342+
command name to local file name. When this package is installed globally,
343+
that file will be either linked inside the global bins directory or
344+
a cmd (Windows Command File) will be created which executes the specified
345+
file in the `bin` field, so it is available to run by `name` or `name.cmd` (on
346+
Windows PowerShell). When this package is installed as a dependency in another
347+
package, the file will be linked where it will be available to that package
348+
either directly by `npm exec` or by name in other scripts when invoking them
349+
via `npm run-script`.
348350

349351

350352
For example, myapp could have this:
@@ -357,8 +359,10 @@ For example, myapp could have this:
357359
}
358360
```
359361

360-
So, when you install myapp, it'll create a symlink from the `cli.js` script
361-
to `/usr/local/bin/myapp`.
362+
So, when you install myapp, in case of unix-like OS it'll create a symlink
363+
from the `cli.js` script to `/usr/local/bin/myapp` and in case of windows it
364+
will create a cmd file usually at `C:\Users\{Username}\AppData\Roaming\npm\myapp.cmd`
365+
which runs the `cli.js` script.
362366

363367
If you have a single executable, and its name should be the name of the
364368
package, then you can just supply it as a string. For example:

0 commit comments

Comments
 (0)