Skip to content

Commit bb2ea29

Browse files
committed
Merge pull request #819 from merriam/master
docs(guide): create guide for Installing The Kit
2 parents 5b47ba1 + c554007 commit bb2ea29

File tree

9 files changed

+93
-0
lines changed

9 files changed

+93
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ A demonstration of this app can be seen [running on heroku](https://react-redux.
7979
## Documentation
8080

8181
* [Exploring the Demo App](docs/ExploringTheDemoApp/ExploringTheDemoApp.md) is a guide that can be used before you install the kit.
82+
* [Installing the Kit](docs/InstallingTheKit/InstallingTheKit.md) guides you through installation and running the development server locally.
8283
* [React Tutorial - Converting Reflux to Redux](http://engineering.wework.com/process/2015/10/01/react-reflux-to-redux/), by Matt Star
8384
If you are the kind of person that learns best by following along a tutorial, I can recommend Matt Star's overview and examples.
8485

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Installing the Kit
2+
3+
Are you ready to install the kit and start playing with it? No? Good. Let's begin.
4+
5+
There is no failure except when nothing is learned.
6+
7+
## Clone from github
8+
9+
First you should clone the project from GitHub. The easiest way is to use something like this:
10+
11+
![Cloning from GitHub](git_clone.png)
12+
13+
This puts a copy of the whole project into your directory `mycopy`. All the files you will change are
14+
in this directory. You can `rm -rf mycopy`, clone it again, and continue on.
15+
16+
That's the minimum view of git, equivalent to the [xkcd view](https://xkcd.com/1597/). Git and
17+
[github](https://github.com) make every manipulation and automated workflow possible but none easy.
18+
Nothing more complex than creating new copy is necessary until contributing code to a project.
19+
20+
21+
## Run npm install
22+
23+
Only part of the project is stored in github. All the JavaScript libraries upon which the project depends
24+
are imported using npm, the node package manager. It might be a good time to check that your version of `npm` is
25+
up to date; OS/X users type `brew upgrade && brew update`.
26+
27+
Npm installs libraries according to the [semvar](https://docs.npmjs.com/getting-started/semantic-versioning)
28+
minimum versions in the `dependencies` section of `package.json` file:
29+
30+
![The Dependencies](dependencies.png)
31+
32+
We also install the packages listed in the `devDependencies` section,
33+
[because we are installing from source](http://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies).
34+
Every package also has its own `package.json` file containing more dependencies. Multiple versions
35+
of the same packages may be listed as dependencies causing copies to be installed in package subdirectories
36+
`./node_modules/*/node_modules`, `./node_modules/*/node_modules/*/node_modules`, etc. This accumulates
37+
to over 1,000 packages.
38+
39+
### Let's install a thousand packages:
40+
41+
![Start of install](start_npm.png)
42+
43+
And then you should see pages and pages of output. Some packages suggest installing "globally" or "-g"; don't.
44+
Global packages install into `/usr/local/lib/node_modules` and mix links to binaries into `/usr/local/bin`.
45+
Local packages install into `./node_modules` with the links to binaries separate in `./node_modules/.bin`.
46+
This provides you the to option of doing a `rm -rf node_modules && npm install` to get back to a known state.
47+
48+
This installation step fails some days; the kit juggles many moving parts and these packages are independently
49+
developed. Some packages have [peer dependencies](https://nodejs.org/en/blog/npm/peer-dependencies/)
50+
which end up conflicting with one another. You can check the
51+
[open install issues](https://github.com/erikras/react-redux-universal-hot-example/issues?utf8=✓&q=is%3Aissue+is%3Aopen+install),
52+
run `npm install` again, or try `npm outdated && npm update`. Errors in installation are often not caught by
53+
running `npm run test`. The only way to know it works is to run it.
54+
55+
## Run the Development Server
56+
57+
First, find the command.
58+
59+
![List of scripts](npm_run.png)
60+
61+
Now, run it!
62+
63+
![Run dev, part 1](run_dev1.png)
64+
65+
We run:
66+
67+
* A *watch client* to trigger webpack to rebuild if we change code.
68+
* A *restful api server* listening on port 3030 to handle requests in JSON format.
69+
* A *webpack dev server* which serves your application on port 3000. It also grabs port 3001
70+
for status and internal information, such as [polling middleware](http://localhost:3001/__webpack_hmr).
71+
You could try installing [BrowserSync](https://www.browsersync.io) to see something more interesting.
72+
73+
The second part shows these running:
74+
75+
![Run dev, part 2](run_dev2.png)
76+
77+
You can see WebPack rebuilding static assets into `./webpack-assets.json`. If you check the id, you
78+
can also view it on port 3001, http://localhost:3001/dist/main-b6c55eaa1c8d8efc7190.js in this example.
79+
80+
Now, open up your browser to [port 3000](http://localhost:3000/):
81+
82+
![Port 3000](port3000.png)
83+
84+
The Redux developer bar takes up much of the screen. Hide it with 'H'.
85+
86+
You are now running the kit on your local machine.
87+
88+
89+
# The Take Away
90+
91+
You cloned the repository, installed all the packages, and ran the development server locally.
92+
You are now ready to hack on the application.
214 KB
Loading

docs/InstallingTheKit/git_clone.png

40.2 KB
Loading

docs/InstallingTheKit/npm_run.png

145 KB
Loading

docs/InstallingTheKit/port3000.png

159 KB
Loading

docs/InstallingTheKit/run_dev1.png

165 KB
Loading

docs/InstallingTheKit/run_dev2.png

116 KB
Loading

docs/InstallingTheKit/start_npm.png

63.6 KB
Loading

0 commit comments

Comments
 (0)