Skip to content

Commit d20537b

Browse files
booshwing328
authored andcommitted
Clarify the Javascript README for local use (#6044)
- Add instructions for installing the generated Javascript library locally without publishing to a remote npm registry. - Clarify what `main.js` is.
1 parent dd8d59b commit d20537b

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

modules/swagger-codegen/src/main/resources/Javascript/README.mustache

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,30 @@ Then install it via:
3131
npm install {{{projectName}}} --save
3232
```
3333

34+
##### Local development
35+
36+
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing
37+
into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:
38+
39+
```shell
40+
npm install
41+
```
42+
43+
Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:
44+
45+
```shell
46+
npm link
47+
```
48+
49+
Finally, switch to the directory you want to use your {{{projectName}}} from, and run:
50+
51+
```shell
52+
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
53+
```
54+
55+
You should now be able to `require('{{{projectName}}}')` in javascript files from the directory you ran the last
56+
command above from.
57+
3458
#### git
3559
#
3660
If the library is hosted at a git repository, e.g.
@@ -45,7 +69,8 @@ then install it via:
4569

4670
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
4771
the above steps with Node.js and installing browserify with `npm install -g browserify`,
48-
perform the following (assuming *main.js* is your entry file):
72+
perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually
73+
use this library):
4974

5075
```shell
5176
browserify main.js > bundle.js

0 commit comments

Comments
 (0)