Errors during "Upload Test Data" step in CHT Local Setup (following official documentation)

Hi all,

I’m encountering build errors during the Upload Test Data section of the Local Setup guide at docs.communityhealthtoolkit.org/building/local-setup/. I’ve followed that documentation, and I am currently running 4.21.0.

Here’s the full context and error output:

salmanfatahillah in Salmans-MacBook-Air in cht-core/config/default on  master is 📦 v0.1.0 via  v20.16.0 
❯ cht --url=https://medic:password@127-0-0-1.local-ip.medicmobile.org:10443/ --accept-self-signed-certs
WARN Project has no dependency on cht-conf. 
INFO Checking that https://medic:****@127-0-0-1.local-ip.medicmobile.org:10443/medic/ is available... 
(node:50240) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
INFO Processing config in default. 
INFO Actions:
     - check-git
     - compile-app-settings
     - backup-app-settings
     - upload-app-settings
     - convert-app-forms
     - convert-collect-forms
     - convert-contact-forms
     - convert-training-forms
     - validate-app-forms
     - validate-collect-forms
     - validate-contact-forms
     - validate-training-forms
     - backup-all-forms
     - delete-all-forms
     - upload-app-forms
     - upload-collect-forms
     - upload-contact-forms
     - upload-training-forms
     - upload-resources
     - upload-branding
     - upload-partners
     - upload-custom-translations
     - upload-privacy-policies
     - upload-extension-libs
     - upload-database-indexes 
INFO Starting action: check-git… 
INFO Fetching git upstream... 
INFO check-git complete. 
INFO Starting action: compile-app-settings… 
WARN app_settings.json file should not be edited directly.
    Please create a base_settings.json file in app_settings folder and move any manually defined configurations there. 
INFO Packaging contact-summary 
INFO assets by status 15.1 KiB [cached] 1 asset
modules by path ../../../../.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/src/contac...(truncated) 3.6 KiB
  ../../../../.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/src/contact-...(truncated) 203 bytes [built] [code generated]
  ../../../../.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/src/contact-su...(truncated) 3.41 KiB [built] [code generated]
modules by path ./*.js 31.7 KiB
  ./contact-summary.templated.js 15.8 KiB [built] [code generated]
  ./contact-summary-extras.js 15.9 KiB [built] [code generated]

ERROR in ./contact-summary-extras.js 1:15-32
Module not found: Error: Can't resolve 'moment' in '/Users/salmanfatahillah/CHT/cht-core/config/default'
 @ ./contact-summary.templated.js 2:15-50
 @ ../../../../.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/src/contact-summary/lib.js 1:21-60

ERROR in ./contact-summary.templated.js 1:15-32
Module not found: Error: Can't resolve 'moment' in '/Users/salmanfatahillah/CHT/cht-core/config/default'
 @ ../../../../.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/src/contact-summary/lib.js 1:21-60

ERROR in [eslint] Failed to load config "@medic" to extend from.
Referenced from: /Users/salmanfatahillah/CHT/cht-core/config/default/.eslintrc

2 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.100.1 compiled with 3 errors in 405 ms 
INFO Error: Webpack errors when building contact-summary
    at /Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/src/lib/compilation/package-lib.js:89:23
    at finalCallback (/Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/webpack/lib/Compiler.js:521:32)
    at /Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/webpack/lib/Compiler.js:545:13
    at Hook.eval [as callAsync] (eval at create (/Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/tapable/lib/Hook.js:20:14)
    at onCompiled (/Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/webpack/lib/Compiler.js:543:21)
    at /Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/webpack/lib/Compiler.js:1377:17
    at Hook.eval [as callAsync] (eval at create (/Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/tapable/lib/Hook.js:20:14)
    at /Users/salmanfatahillah/.nvm/versions/node/v20.16.0/lib/node_modules/cht-conf/node_modules/webpack/lib/Compiler.js:1373:33 
ERROR Webpack errors when building contact-summary 

For context, I launched my local CHT instance using this command:

salmanfatahillah in Salmans-MacBook-Air in cht-core/scripts/docker-helper-4.x on  master took 4s 
❯ ./cht-docker-compose.sh                          
No project found, follow the prompts to create a project .env file.

Would you like to initialize a new project [y/N]? y

Do you want to run the latest CHT Core version (4.21.0) [Y/n]? Y  

How do you want to name the project? reference-app

Downloading compose files ... done 

homedir: /Users/salmanfatahillah/.medic/cht-docker/reference_app-dir
[+] Running 2/2
 ✔ Network reference_app-cht-net                      Created                                                                                   0.0s 
 ✔ Container reference_app-dir-cht-upgrade-service-1  Started                                                                                   0.2s 
Starting project "reference_app". First run takes a while. Will try for up to five minutes.......


 -------------------------------------------------------- 

  Success! "reference_app" is set up:

    https://127-0-0-1.local-ip.medicmobile.org:10443/ (CHT)
    https://127-0-0-1.local-ip.medicmobile.org:10443/_utils/ (Fauxton)

    Login: medic
    Password: password

 -------------------------------------------------------- 

Start existing project
    ./cht-docker-compose.sh ENV-FILE.env

Stop and keep project:
    ./cht-docker-compose.sh ENV-FILE.env stop

Stop and destroy all project data:
    ./cht-docker-compose.sh ENV-FILE.env destroy

https://docs.communityhealthtoolkit.org/hosting/4.x/app-developer/


 Have a great day! 

The instance itself runs fine, and I’m able to access both the CHT app and Fauxton UI at the expected URLs.

However, it took me quite a while to realize that this part of the documentation:

cht --url=https://medic:password@localhost --accept-self-signed-certs
cht --url=https://medic:password@localhost --accept-self-signed-certs csv-to-docs upload-docs

…actually expects me to replace localhost with the full local domain generated by the helper script, which in my case is 127-0-0-1.local-ip.medicmobile.org:10443. I only realised this a few weeks ago.

It would be helpful if the docs clarified this for users who are running via Docker and following the default cht-docker-compose.sh setup.


Any advice would be appreciated. Happy to share more logs or version details if needed. Thanks in advance!

@salmaniye - welcome to the CHT Forums! Thanks so much for submitting such a thoughtful and thorough first post. Amazing work here!

I wonder if you ran npm ci before calling cht-conf? Here’s the excerpt from the docs:

If the above command shows an error similar to this one ERROR Error: Webpack warnings when building contact-summary you will need to install all the dependencies and libraries it needs (by running npm ci) before trying to upload the configuration again with the cht ... command.

Please try calling that and then making your CLI call again (cht --url=https://medic:passw... etc) and report back with your results!

Separately, I’ll look into how the docs work with the localhost vs the Local IP URLs with https and an IP address. Thanks for the feedback!

@salmaniye - Ok - hold off on that npm ci call please :sweat_smile: ! Sorry for the change of plans, but It turns out we removed the package-lock.json needed to easily run npm ci. I was unable to reproduce your error ( Error: Can't resolve 'moment), but when I tested running npm ci I got another error about the missing file.

@diana - when you get a sec can you advise on the issue here? Would adding a package lock file (which gets us around the The npm ci command can only install with an existing package-lock.json) solve the the npm ci error and thus help salmaniye with the moment error?

Thanks!


@salmaniye - On the docs issue, I’ll review the URLs and instructions, but I agree that it’s confusing when to use localhost vs the URL with your local-ip in it:

@salmaniye - some updates here: there’s a new documentation issue filed to improve the local setup docs

2 Likes

Hi @mrjones, thank you so much for your replies and for opening the documentation issue on GitHub, I really appreciate the effort!

Just to add some context: what I originally aimed to do was understand how the .xlsx forms are converted into the resulting .xml forms after running convert-app-forms. Since the Maternal and Newborn Health reference app was highlighted in the getting started guide, I assumed it followed the current best practices and would serve as the standard for how things should be structured.

I’m currently working on a project in my country, specifically for Tuberculosis workflows. I tried adapting the forms from cht-pih-malawi-app since they include TBC workflows, but I believe some of the files might be outdated, although I’m not entirely sure. I can provide the errors logs of my attempt at uploading the files to the 4.21.0 too in another post perhaps.

I can of course bypass the form validation using --skip-validate and the forms do show up in the app, but I’d like it to be as stable as possible and ideally pass all validation checks.

Thanks again!! :folded_hands:

Thanks for the update @salmaniye !

One thing you might double check is that you’ve properly installed CHT Conf and that it’s up to do date. Can you double check:

  • You have the latest version by calling npm update cht-conf
  • You have pyxform-medic installed per the docs?

You can check which version your running with cht --version like so:

cht --version      
INFO 4.8.1 

You can see I need to update to a later version - the latest is 5.1.0!

Separate from that, you can have CHT Conf convert just one form which is handy when you trying to quickly iterate on changes of just one form. You can do this by passing in the form name after the convert-app-forms command. For example, if you wanted to convert the forms/app/pregnancy_danger_sign_follow_up.xlsx you would call:

cht convert-app-forms -- pregnancy_danger_sign_follow_up

For me this looks like:

$ cht convert-app-forms -- pregnancy_danger_sign_follow_up     

WARN Project has no dependency on cht-conf. 
INFO Processing config in default. 
INFO Actions:
     - convert-app-forms 
INFO Starting action: convert-app-forms… 
INFO Converting form /var/home/mrjones/Documents/MedicMobile/cht-core/config/default/forms/app/pregnancy_danger_sign_follow_up.xlsx … 
Conversion complete!
INFO convert-app-forms complete. 

And then you can see the resulting .xlsx file in forms/app/pregnancy_danger_sign_follow_up.xlsx

Running the simplified CHT Conf command, upgrading to the latest version and double checking for pyxform-medic hopefully will help!