@@ -16,8 +16,8 @@ The ``require()`` and ``load()`` methods include files and modules in
16
16
your scripts for added functionality. However, ``require()`` and
17
17
``load()`` differ in their behaviors and availability.
18
18
19
- Types of Scripts in `` mongosh``
20
- -------------------------------
19
+ Types of Scripts in mongosh
20
+ ---------------------------
21
21
22
22
You can use the following types of scripts with ``mongosh``:
23
23
@@ -30,8 +30,8 @@ You can use the following types of scripts with ``mongosh``:
30
30
- Node.js scripts, which are any scripts loaded with ``require()``,
31
31
including npm packages. These scripts are always files.
32
32
33
- Availability of `` require()`` and `` load()``
34
- --------------------------------------------
33
+ Availability of require() and load()
34
+ ------------------------------------
35
35
36
36
The ``require()`` and ``load()`` methods differ in availability
37
37
depending on the type of script you are using.
@@ -40,8 +40,8 @@ depending on the type of script you are using.
40
40
41
41
- In Node.js scripts, only ``require()`` is available.
42
42
43
- File Paths for `` require()`` and `` load()``
44
- -------------------------------------------
43
+ File Paths for require() and load()
44
+ -----------------------------------
45
45
46
46
The type of script determines how you specify file paths with
47
47
``require()`` or ``load()``.
@@ -73,7 +73,7 @@ The type of script determines how you specify file paths with
73
73
To change the shell's working directory, use the :ref:`cd()
74
74
<mongosh-native-method-cd>` method in your script.
75
75
76
- Load External Code in a `` mongosh`` Script
76
+ Load External Code in a mongosh Script
77
77
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78
78
79
79
You can load external code in a ``mongosh`` script file, such as an npm
@@ -111,8 +111,13 @@ package or a separate ``mongosh`` script.
111
111
const localRequire = require('date-fns').createRequire(__filename);
112
112
const fileExports = localRequire('./test-suite2.js'); }
113
113
114
- Access to the ``mongosh`` API
115
- -----------------------------
114
+ require() Packaging Considerations
115
+ ----------------------------------
116
+
117
+ .. include:: /includes/scripting/fact-require-ems-modules.rst
118
+
119
+ Access to the mongosh API
120
+ -------------------------
116
121
117
122
- ``mongosh`` scripts can use the ``mongosh`` API.
118
123
@@ -134,4 +139,3 @@ available inside of Node.js scripts.
134
139
Generally, you should not keep mongosh-specific code inside Node.js
135
140
scripts.
136
141
137
-
0 commit comments