Client dev install¶
The code for the Hypothesis client (the sidebar) lives in a Git repo named client. Follow this section to get the client running in a local development environment.
See also
The development version of the Hypothesis client currently requires a development version of the Hypothesis website and API, so you should follow Website dev install before following this page.
To install the Hypothesis client in a local development environment:
Clone the
clientgit repo andcdinto it:git clone https://github.com/hypothesis/client.git cd clientInstall the client’s JavaScript dependencies:
npm install
Run the client’s test to make sure everything’s working:
make testLink your website development environment to your development client. Run
npm linkin theclientdirectory thennpm link hypothesisin thehdirectory:client> npm link client> cd ../h h> npm link hypothesisTip
If you get a permission denied error when running
npm linkyou probably need to tell npm to install packages into a directory in your home directory that you have permission to write to. On linux:npm config set prefix /home/<YOUR_USERNAME>/npmOn macOS:
npm config set prefix /Users/<YOUR_USERNAME>/npmnpm will now install executable files into
$HOME/npm/bin, so add that directory to your$PATH.Both your website development environment and the live reload server (see below) in your client development environment will now use your development client instead of the built client from npm.
To unlink your website run
npm unlink hypothesisthenmake cleanin thehdirectory, your website development environment and the live reload server will both go back to using the built client from npm:h> npm unlink hypothesis h> make clean dev
You can now test the client in a web browser by running the live reload server.
Note
The live reload server uses the Hypothesis client from your website development environment, not the client from your client development environment!
By default your website dev env serves up the built client from npm. Make sure you’ve linked your website dev env to your client dev env (see above) so that your website serves up the client from your client dev env, then the live reload server will use your dev client as well.
First run the web service on http://localhost:5000/, the client won’t work without this because it sends HTTP requests to http://localhost:5000/ to fetch and to save annotations. In the
hdirectory run:h> make dev
Now in another terminal, in the
clientdirectory, run the live reload server:client> gulp watch
Now open http://localhost:3000/ in a browser to see the client running in the live reload server. The live reload server automatically reloads the client whenever you modify any of its styles, templates or scripts.