|
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 60 | + |
| 61 | +Now, run it! |
| 62 | + |
| 63 | + |
| 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 | + |
| 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 | + |
| 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. |
0 commit comments