-
Notifications
You must be signed in to change notification settings - Fork 73
Dev setup
The following global tools are recommended to simplify development:
-
NVM - lets you manage multiple versions of Node on one machine (the version this project currently uses is in
.nvmrc
). -
direnv
- lets you manage environment variables (and the active version of Node) based on the.envrc
of the directory you're in.
-
Go to https://github.com/textbook/starter-kit/generate (or click "Use this template") to create your own version of this repository
-
Clone the new repository to your local machine.
-
cd
into the repository's directory on your local machine. You can rungit status
to check you're in the right place, it should say something likeOn branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean
-
If you have
direnv
installed, you may seedirenv: error .envrc is blocked. Run `direnv allow` to approve its content.
If you trust the repo, you can run
direnv allow
as suggested.
-
-
Install the dependencies by running
npm install
; this will create anode_modules/
directory and fill it with the requirements specified inpackage.json
andpackage-lock.json
. -
Run the app using either
npm run dev
(developer mode, with watching/reloading of your code as you make changes) ornpm run serve
(production mode, to check what will actually get deployed) - see Scripts for more details. -
While one of those two scripts is running, visit http://localhost:3000 to see the app:
If you see any errors, or the site doesn't look like the image above, check out Home#Common errors.
If you see EADDRINUSE
when trying to run dev
or serve
, you may have other processes running on your machine that are using ports the starter kit expects. You can check which processes these are using the command:
lsof -i :<port>
If you see existing npm
commands running, you may have terminals running in the background somewhere - find them and stop them! If you see some other program running, you may need to switch ports. You can do this as follows:
-
npm run dev
:-
Frontend (default: 3000): you need to change the line
port: 3000,
inclient/webpack/dev.config.js
-
Backend (default: 3100): you need to change this in two places, the line
"/api": "http://localhost:3100",
inclient/webpack/dev.config.js
and the line"dev:serve": "wait-on -l file:dist/server.js && cross-env PORT=3100 nodemon dist/server.js --watch dist",
inpackage.json
.
-
Frontend (default: 3000): you need to change the line
-
npm run serve
:-
Backend (default: 3000): the easiest way to override this is when you actually run the server, so you can do e.g.
PORT=3210 npm run serve
. Alternatively you can change the lineconst port = parseInt(process.env.PORT || "3000");
inserver/server.js
.
-
Backend (default: 3000): the easiest way to override this is when you actually run the server, so you can do e.g.