Lines Matching +full:packages +full:- +full:dir
3 <!--introduced_in=v0.10.0-->
5 > Stability: 2 - Stable
7 <!--name=module-->
39 in a function by Node.js (see [module wrapper](#the-module-wrapper)).
72 <!-- type=misc -->
81 contains a top-level field [`"type"`][] with a value of `"commonjs"`.
84 doesn't contain a top-level field [`"type"`][]. Package authors should include
85 the [`"type"`][] field, even in packages where all sources are CommonJS. Being
91 (when the nearest parent `package.json` file contains a top-level field
94 used as the command-line entry point of the program).
103 <!-- type=misc -->
117 <!-- type=misc -->
122 native packages from Node.js modules without modification.
127 `/usr/lib/node/<some-package>/<some-version>` hold the contents of a
130 Packages can depend on one another. In order to install package `foo`, it
136 … then [looks for their dependencies in `node_modules` folders](#loading-from-node_modules-folders),
144 * `/usr/lib/node/bar/4.3.2/node_modules/*`: Symbolic links to the packages that
158 than putting packages directly in `/usr/lib/node`, we could put them in
166 `require()`, the packages themselves can be anywhere.
180 <!-- type=misc -->
185 Putting together all of the above, here is the high-level algorithm
229 2. for each DIR in DIRS:
230 a. LOAD_PACKAGE_EXPORTS(X, DIR)
231 b. LOAD_AS_FILE(DIR/X)
232 c. LOAD_AS_DIRECTORY(DIR/X)
236 2. let I = count of PARTS - 1
240 b. DIR = path join(PARTS[0 .. I] + "node_modules")
241 c. DIRS = DIR + DIRS
242 d. let I = I - 1
245 LOAD_PACKAGE_IMPORTS(X, DIR)
246 1. Find the closest package scope SCOPE to DIR.
250 …["node", "require"]) <a href="esm.md#resolver-algorithm-specification">defined in the ESM resolver…
253 LOAD_PACKAGE_EXPORTS(X, DIR)
256 2. If X does not match this pattern or DIR/NAME/package.json is not a file,
258 3. Parse DIR/NAME/package.json, and look for "exports" field.
260 5. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(DIR/NAME), "." + SUBPATH,
261 …`package.json` "exports", ["node", "require"]) <a href="esm.md#resolver-algorithm-specification">d…
264 LOAD_PACKAGE_SELF(X, DIR)
265 1. Find the closest package scope SCOPE to DIR.
271 <a href="esm.md#resolver-algorithm-specification">defined in the ESM resolver</a>.
283 <!--type=misc-->
299 <!--type=misc-->
306 Additionally, on case-insensitive file systems or operating systems, different
314 <!--type=misc-->
316 <!-- YAML
318 - version:
319 - v16.0.0
320 - v14.18.0
321 pr-url: https://github.com/nodejs/node/pull/37246
323 -->
338 return the built-in HTTP module, even if there is a file by that name. The list
344 <!--type=misc-->
408 <!--type=misc-->
438 <!--type=misc-->
440 > Stability: 3 - Legacy: Use [subpath exports][] or [subpath imports][] instead.
450 { "name" : "some-library",
451 "main" : "./lib/some-library.js" }
454 If this was in a folder at `./some-library`, then
455 `require('./some-library')` would attempt to load
456 `./some-library/lib/some-library.js`.
462 example, then `require('./some-library')` would attempt to load:
464 * `./some-library/index.js`
465 * `./some-library/index.node`
471 Error: Cannot find module 'some-library'
474 In all three above cases, an `import('./some-library')` call would result in a
481 <!--type=misc-->
484 [core](#core-modules) module, and does not begin with `'/'`, `'../'`, or
507 `require('example-module/path/to/file')` would resolve `path/to/file`
508 relative to where `example-module` is located. The suffixed path follows the
513 <!-- type=misc -->
515 If the `NODE_PATH` environment variable is set to a colon-delimited list
547 <!-- type=misc -->
560 * It keeps top-level variables (defined with `var`, `const`, or `let`) scoped to
562 * It helps to provide some global-looking variables that are actually specific
573 <!-- YAML
575 -->
577 <!-- type=var -->
595 <!-- YAML
597 -->
599 <!-- type=var -->
634 <!-- YAML
636 -->
638 <!-- type=var -->
648 <!-- YAML
650 -->
652 <!-- type=var -->
662 <!-- YAML
664 -->
666 <!-- type=var -->
687 // Importing a module from node_modules or Node.js built-in module:
693 <!-- YAML
695 -->
705 built-in modules and if a name matching a built-in module is added to the cache,
706 only `node:`-prefixed require calls are going to receive the built-in module.
709 <!-- eslint-disable node-core/no-duplicate-requires -->
724 <!-- YAML
727 -->
729 > Stability: 0 - Deprecated
741 **Deprecated.** In the past, this list has been used to load non-JavaScript
742 modules into Node.js by compiling them on-demand. However, in practice, there
751 <!-- YAML
753 -->
760 See ["Accessing the main module"](#accessing-the-main-module).
772 <!-- eslint-skip -->
791 <!-- YAML
794 - version: v8.9.0
795 pr-url: https://github.com/nodejs/node/pull/16397
797 -->
816 <!-- YAML
818 -->
829 <!-- YAML
831 -->
833 <!-- type=var -->
835 <!-- name=module -->
841 also accessible via the `exports` module-global. `module` is not actually
846 <!-- YAML
848 -->
856 <!-- YAML
858 -->
911 <!-- YAML
913 -->
915 The `exports` variable is available within a module's file-level scope, and is
930 <!-- eslint-disable func-name-matching -->
960 <!-- YAML
962 -->
970 <!-- YAML
972 -->
981 <!-- YAML
983 - v15.4.0
984 - v14.17.0
985 -->
992 <!-- YAML
994 -->
1003 <!-- YAML
1006 - v14.6.0
1007 - v12.19.0
1008 -->
1010 > Stability: 0 - Deprecated: Please use [`require.main`][] and
1021 <!-- YAML
1023 -->
1032 <!-- YAML
1034 -->
1042 <!-- YAML
1044 -->
1060 [Modules: `module` core module](module.md#the-module-object).
1062 <!-- Anchors to make sure old links find a target -->
1071 [Modules: `module` core module](module.md#source-map-v3-support).
1073 <!-- Anchors to make sure old links find a target -->
1076 * <a id="modules_class_module_sourcemap" href="module.html#class-modulesourcemap">Class: `module.So…
1077 …* <a id="modules_new_sourcemap_payload" href="module.html#new-sourcemappayload">`new SourceMap(pay…
1079 …ntry_linenumber_columnnumber" href="module.html#sourcemapfindentrylinenumber-columnnumber">`source…
1081 [Determining module system]: packages.md#determining-module-system
1083 [GLOBAL_FOLDERS]: #loading-from-the-global-folders
1084 [`"main"`]: packages.md#main
1085 [`"type"`]: packages.md#type
1091 [`import()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import
1096 [`module` object]: #the-module-object
1097 [`package.json`]: packages.md#nodejs-packagejson-field-definitions
1100 [exports shortcut]: #exports-shortcut
1101 [module resolution]: #all-together
1103 [subpath exports]: packages.md#subpath-exports
1104 [subpath imports]: packages.md#subpath-imports