Skip to content

Latest commit

 

History

History
executable file
·
120 lines (86 loc) · 3.63 KB

INSTALL.md

File metadata and controls

executable file
·
120 lines (86 loc) · 3.63 KB

Install/Deployment

The webclient requires npm, the Node.js package manager (please follow the instructions for installing from http://npmjs.org). After the initial git clone/pull/update of the code from the repo. To install the required Node packages (for testing, the UI, code checks, etc.) need to run

npm install

If you're deploying the code somewhere remotely without the need to run unit tests, checks, etc., only the npm packages for production are needed.

npm install --production

This installs the latest required npm packages. You will only need to re-run this if the package requirements (from package.json or required versions) have changed. Its important to run this command after you pull changes from the repo if the actual package.json may has changed.

Note: Generally "production" will mean that no externally used packages will be pulled in. In our case "production" means to pull in everything that is used to build the production dependencies, which is much leaner than the full development install.

Development Environment

Since adding React to our toolkit (because of the needs and requirements added by the MEGAchat), there is a new file (js/chat/bundle.js) to be generated to run the code (it is not available in the repository).

This file is generated by webpack, and depending on the environment you may run the webclient in development in two different methods.

A simple script watches for changes in React UI related files, generates required artifacts automatically (in memory, no files generated), serves them (via HTTP), and updates the UI with changes live (including relevant code reloads). This process is very fast, easy and efficient. You will get this convenience just by running the following:

scripts/dev_server.sh

Tip: DON'T use the http://localhost:8089/webpack-dev-server/ url (because it uses an iframe for webpack, which is very annoying) for developing/debugging. Just type in: http://localhost:8089/ (or http://localhost:8089/dont-deploy/devboot.html).

Demo/Beta Environment

Those are mostly used for demonstrating something internally or on https://beta.mega.nz. This type of deployment is basically done after cloning the specific/target feature branch on the webserver via SSH. The required React bundles (see above) are simply generated via a script in place after installing the npm package dependencies:

npm install --production && scripts/build.sh

When doing updates to that folder on the server, just do a:

git pull -u && npm install --production && scripts/build.sh

That ensures that everything is consistently up to date.

Running a Development or Demo/Beta Environment

The webclient will also require some localStorage variables set so that it works as expected:

localStorage.d = '1';
localStorage.dd = '1';
localStorage.jj = '1';
// Will add a ?r=Date() to enforce browser cache to be disabled.
localStorage.jjnocache = '1';

You may find some prepared "devboot" HTML files for launch in the dont-deploy/ folder.

Usual problems and solutions

  1. Generic js errors that something is undefined, can't be called, etc.

Please ensure that you are running newer nodejs and npm versions.

  1. core-js/ related errors, when starting dev_server.sh/build.sh

Please ensure that you are running newer nodejs and npm versions and then just do

rm -rf node_modules && npm cache clear && npm install

and you should be able to run the dev_server.sh again.