UNPKG

3.19 kBMarkdownView Raw
1
2## Installing swagger
3
4* [Prerequisites](#prereqs)
5* [Installing with npm](#install)
6* [Using npm without sudo](#nosudo)
7* [Configuring the default browser in Linux](#defaultbrowser)
8
9### <a name="prereqs"></a>Prerequisites
10
11* [Node.js](http://nodejs.org/download/) (v0.10.24+)
12* [npm](https://docs.npmjs.com/getting-started/installing-node) (v1.3.0+)
13
14### <a name="install"></a>Installing with npm
15
16The `swagger` module is designed for Node.js and is available through npm.
17
18#### Installing on Linux / Mac
19
20Here's how you install with `sudo`. If you do not wish to use `sudo`, see [Using npm without sudo](#nosudo) below.
21
221. Open a terminal.
232. Run the install:
24
25 `sudo npm install -g swagger`
26
27**Note**: `sudo` may or may not be required with the `-g` option depending on your configuration. If you do not use `-g`, you may need to add the `swagger/bin` directory to your PATH manually. On Unix-based machines
28the bin directory will often be found here: `/usr/local/lib/node_modules/swagger/bin`.
29
30#### Installing on Windows
31
321. Open a terminal.
332. Run the install:
34
35 `npm install -g swagger`
36
37## <a name="nosudo"></a>Using npm without sudo
38
39If you don't want to use sudo to install swagger on your system, follow the instructions in this section.
40
41#### Overview
42
43By default npm will place 'global' modules installed with the `-g` flag in `/usr/local/lib/node_modules` using the default prefix of `/usr/local`. Global executables would be placed in `/usr/local/bin` using the same default prefix, thereby putting them on the default PATH in most cases. In order to write to both of these directories root permissions are required.
44
45Many Node.js developers choose to use a different prefix such that they do not need to use root permissions to install modules using the `-g` flag (rightfully so - you should always be wary about things that 'require root permissions'!). Using root permissions is effectively a shortcut. In order to use executables installed using a different prefix you need to add an element to your path.
46
47#### Steps
48
491. Set the 'prefix' for npm by using the following command (documented here: [npm-config](https://www.npmjs.org/doc/misc/npm-config.html). This will create a file `~/.npmrc` that contains configuration information for npm.
50
51```bash
52 npm set prefix ~/npm
53```
54
552. Edit your `.bash_profile` or the appropriate shell initialization script to add `~/npm` to your `PATH` by adding the following line (or placing the single line in the new file if it does not exist):
56
57 ```bash
58 PATH=~/npm/bin:$PATH
59 ```
60
61 This will enable you to easily use executable scripts installed using `-g` through npm - both for swagger and for other tools as well!
62
63###<a name="defaultbrowser"></a>Configuring the default browser on Linux
64
65On Linux platforms, you need to specify your browser path before using the Swagger editor.
66
671. Create or open the following file in a text editor:
68
69 `~/.a127/config.js`
70
712. Add the following contents to the file:
72
73 ```javascript
74 module.exports = {
75 browser: ’the/path/to/your/browser'
76 };
77 ```