Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Document require.main doesn't work as usual in bin file.

  • Loading branch information...
commit 19206eea4a10e09e6adfe855e2c35ff7034ed36f 1 parent 8d0cfdb
@5long 5long authored isaacs committed
Showing with 13 additions and 0 deletions.
  1. +6 −0 doc/json.md
  2. +7 −0 man1/json.1
View
6 doc/json.md
@@ -109,6 +109,12 @@ So, when you install npm, it'll create a symlink from the `cli.js` script to
`/usr/local/bin/npm-version`. Then, when you activate that version, it'll
create a symlink from `/usr/local/bin/npm-version` to `/usr/local/bin/npm`.
+Notice that if the executable file is interpreted by node (i.e., specifying
+node in the shebang line), npm actually installs a shim instead of symlinking
+it, which causes expressions `require.main === module` and `module.id === "."`
+evaluate to `false` within the file. This seems unable to be resolved until
+node provides a "flexible `require()`".
+
Shortcut: If you have a single executable, and its name is already what you
want it to be, then you can just supply it as a string. For example:
View
7 man1/json.1
@@ -152,6 +152,13 @@ So, when you install npm, it\'ll create a symlink from the \fBcli\.js\fR script
create a symlink from \fB/usr/local/bin/npm\-version\fR to \fB/usr/local/bin/npm\fR\|\.
.
.P
+Notice that if the executable file is interpreted by node (i\.e\., specifying
+node in the shebang line), npm actually installs a shim instead of symlinking
+it, which causes expressions \fBrequire\.main === module\fR and \fBmodule\.id === "\."\fR
+evaluate to \fBfalse\fR within the file\. This seems unable to be resolved until
+node provides a "flexible \fBrequire()\fR"\.
+.
+.P
Shortcut: If you have a single executable, and its name is already what you
want it to be, then you can just supply it as a string\. For example:
.
Please sign in to comment.
Something went wrong with that request. Please try again.