Browse Source

doc: recommend against use of NODE_PATH

PR-URL: https://github.com/nodejs/io.js/pull/1708
Reviewed-By: Roman Reiss <me@silverwind.io>
v2.3.1-release
smikes 10 years ago
committed by Roman Reiss
parent
commit
7d90c90aaf
  1. 18
      doc/api/modules.markdown

18
doc/api/modules.markdown

@ -429,6 +429,18 @@ of absolute paths, then io.js will search those paths for modules if they
are not found elsewhere. (Note: On Windows, `NODE_PATH` is delimited by are not found elsewhere. (Note: On Windows, `NODE_PATH` is delimited by
semicolons instead of colons.) semicolons instead of colons.)
`NODE_PATH` was originally created to support loading modules from
varying paths before the current
[module resolution](https://iojs.org/api/modules.html#modules_all_together)
algorithm was frozen.
`NODE_PATH` is still supported, but is less necessary now that the io.js
ecosystem has settled on a convention for locating dependent modules.
Sometimes deployments that rely on `NODE_PATH` show surprising behavior
when people are unaware that `NODE_PATH` must be set. Sometimes a
module's dependencies change, causing a different version (or even a
different module) to be loaded as the `NODE_PATH` is searched.
Additionally, io.js will search in the following locations: Additionally, io.js will search in the following locations:
* 1: `$HOME/.node_modules` * 1: `$HOME/.node_modules`
@ -438,9 +450,9 @@ Additionally, io.js will search in the following locations:
Where `$HOME` is the user's home directory, and `$PREFIX` is io.js's Where `$HOME` is the user's home directory, and `$PREFIX` is io.js's
configured `node_prefix`. configured `node_prefix`.
These are mostly for historic reasons. You are highly encouraged to These are mostly for historic reasons. **You are highly encouraged
place your dependencies locally in `node_modules` folders. They will be to place your dependencies locally in `node_modules` folders.** They
loaded faster, and more reliably. will be loaded faster, and more reliably.
## Accessing the main module ## Accessing the main module

Loading…
Cancel
Save