When you want to write code within the OpenMRS SPA, you will need to follow these instructions for setting up your development environment.
Setting up a SPA development environment
- Install git
- Install node, which includes npm. This is for compiling and bundling frontend code (not for writing backend code).
- Consider installing nvm, which can be used to install specific versions of npm and node as needed.
- Trust insecure localhost SSL certificates.
- Run the following commands:
git clone https://github.com/openmrs/openmrs-esm-patient-chart # or whichever frontend repo you want to work on cd openmrs-esm-patient-chart npm install npm start -- --https --port 8080
- Now go to https://openmrs-spa.org/openmrs/spa/login
- Open the browser console
localStorage.setItem('openmrs:devtools', true)
- Refresh the page. You will now see a floating colored rectangle on the screen. Click on it. A panel will open up
- In the Import Map tab, click on the frontend module that you are working on.
- For all repos except for openmrs-esm-root-config, modify the URL to be
8080
. This will make it so the javascript bundle is loaded from https://localhost:8080 instead of the CDN. For esm-root-config, modify it to be the following fully qualified url: https://localhost:8080/openmrs-esm-root-config.defaults.js - Refresh the page.
- Verify that root-config.js is being downloaded from localhost now. You can do this in the Network tab of the browser dev tools.
- Congrats! You're all set up. Try adding a console.log() statement inside of a file and saving the file. Your web browser will refresh and you should see the console.log inside of the browser console.
Also See
Troubleshooting
If you run into a issue in Chrome where you are unable to proceed with insecure certificates, try running with a separate certificate as follows:
Generate self-signed certificate:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
Use self-signed certificate when starting Node:
npm start -- --https --cert cert.pem --key key.pem
Related articles
Filter by label
There are no items with the selected labels at this time.