Error when initializing the medic-api

Hello @diana

On running grunt dev-api as recommended here i get

Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/src/public/login/style.css" (2.74 kB)
/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html was listed as a dependency for dynamic URL /, but the file does not exist. Either remove the entry as a dependency, or correct the path to the file.
2022-06-20 19:58:53 ERROR: Fatal error initialising medic-api 
2022-06-20 19:58:53 ERROR: { Error: ENOENT: no such file or directory, stat '/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html'
    at Object.statSync (fs.js:855:3)
    at getFileAndSizeAndHashForFile (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:40:17)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:214:22
    at Array.map (<anonymous>)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:212:12
    at Array.forEach (<anonymous>)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:194:50
    at new Promise (<anonymous>)
    at generate (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:128:10)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:346:5
  [stack]:
   'Error: ENOENT: no such file or directory, stat \'/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html\'\n    at Object.statSync (fs.js:855:3)\n    at getFileAndSizeAndHashForFile (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:40:17)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:214:22\n    at Array.map (<anonymous>)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:212:12\n    at Array.forEach (<anonymous>)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:194:50\n    at new Promise (<anonymous>)\n    at generate (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:128:10)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:346:5',
  [message]:
   'ENOENT: no such file or directory, stat \'/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html\'',
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path:
   '/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html' } 
[nodemon] app crashed - waiting for file changes before starting...

the file is not there in the api/extracted-resources folder, where is it being listed as a dependency?, so that i can remove it or change the path …
Or maybe this one

Hi @cliff

More details are needed, can you please include all API startup logs?

1 Like
cliff@cliff-Latitude-5580:~/Documents/project/medic/cht-core/api$ grunt dev-api
Running "exec:api-dev" (exec) task
[nodemon] 2.0.13
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): api/**/* shared-libs/**/src/**
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node --inspect=0.0.0.0:9229 api/server.js --allow-cors`
>> Debugger listening on ws://0.0.0.0:9229/3b745073-fb23-4519-91dd-ef4046a64002
>> For help, see: https://nodejs.org/en/docs/inspector
2022-06-20 19:58:52 WARN: WARNING: allowing CORS requests to API! 
2022-06-20 19:58:52 INFO: Running server checks… 
Node Environment Options: 'undefined'
Node Version: 10.24.1 in development mode
COUCH_URL http://localhost:5984/medic
COUCH_NODE_NAME nonode@nohost
Environment variable "COUCH_NODE_NAME" matches server "nonode@nohost"
CouchDB Version: 2.3.1
2022-06-20 19:58:52 INFO: Checks passed successfully 
2022-06-20 19:58:52 INFO: Extracting ddoc… 
2022-06-20 19:58:53 INFO: DDoc extraction completed successfully 
2022-06-20 19:58:53 INFO: Cleaning resources directory… 
2022-06-20 19:58:53 INFO: Cleaning resources directory completed successfully 
2022-06-20 19:58:53 INFO: Extracting resources… 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/enketo-icons-v2.ttf 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/enketo-icons-v2.eot 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-chw.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-chw-selected.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-death_report.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-nurse-selected.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-pregnant.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/enketo-icons-v2.woff 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-undo_death_report.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/setup-wizard-demo.png 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/enketo-icons-v2.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon.png 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pregnancy_facility_visit_reminder.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-clinic-edit.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-nurse.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/layers.png 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-district_hospital-edit.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-pregnant-selected.svg 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/audio/alert.mp3 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/NotoSans-Regular.ttf 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pnc_danger_sign_follow_up_mother.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pnc_danger_sign_follow_up_baby.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/NotoSans-Italic.ttf 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-health_center-edit.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/NotoSans-Bold.ttf 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pregnancy_danger_sign.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/resources.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pregnancy_danger_sign_follow_up.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/messages-en.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-person-create.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-district_hospital-create.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-health_center-create.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-clinic-create.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-contact-person-edit.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/NotoSans-BoldItalic.ttf 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/settings.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pregnancy.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-delivery.doc.json 
2022-06-20 19:58:53 DEBUG: Extracted attachment /home/cliff/Documents/project/medic/cht-core/api/extracted-resources/default-docs/form-pregnancy_home_visit.doc.json 
2022-06-20 19:58:53 INFO: Extracting resources completed successfully 
2022-06-20 19:58:53 INFO: Extracting initial documents… 
2022-06-20 19:58:53 INFO: Extracting initial documents completed successfully 
2022-06-20 19:58:53 INFO: Loading configuration… 
2022-06-20 19:58:53 INFO: Not updating settings - the existing settings are already up to date 
2022-06-20 19:58:53 WARN: Disabled transition "update_clinics" 
2022-06-20 19:58:53 WARN: Disabled transition "self_report" 
2022-06-20 19:58:53 WARN: Disabled transition "registration" 
2022-06-20 19:58:53 WARN: Disabled transition "accept_patient_reports" 
2022-06-20 19:58:53 WARN: Disabled transition "accept_case_reports" 
2022-06-20 19:58:53 WARN: Disabled transition "generate_shortcode_on_contacts" 
2022-06-20 19:58:53 INFO: Loading transition "generate_patient_id_on_people" 
2022-06-20 19:58:53 INFO: Skipping asynchronous transition "generate_patient_id_on_people" 
2022-06-20 19:58:53 WARN: Disabled transition "default_responses" 
2022-06-20 19:58:53 WARN: Disabled transition "update_sent_by" 
2022-06-20 19:58:53 WARN: Disabled transition "update_sent_forms" 
2022-06-20 19:58:53 INFO: Loading transition "death_reporting" 
2022-06-20 19:58:53 WARN: Disabled transition "conditional_alerts" 
2022-06-20 19:58:53 WARN: Disabled transition "multi_report_alerts" 
2022-06-20 19:58:53 WARN: Disabled transition "update_notifications" 
2022-06-20 19:58:53 WARN: Disabled transition "update_scheduled_reports" 
2022-06-20 19:58:53 WARN: Disabled transition "resolve_pending" 
2022-06-20 19:58:53 WARN: Disabled transition "muting" 
2022-06-20 19:58:53 WARN: Disabled transition "mark_for_outbound" 
2022-06-20 19:58:53 INFO: Configuration loaded successfully 
2022-06-20 19:58:53 INFO: Merging translations… 
2022-06-20 19:58:53 INFO: Translations merged successfully 
2022-06-20 19:58:53 INFO: Running db migrations… 
2022-06-20 19:58:53 INFO: Database migrations completed successfully 
2022-06-20 19:58:53 INFO: Generating manifest 
2022-06-20 19:58:53 INFO: Manifest generated successfully 
2022-06-20 19:58:53 INFO: Generating service worker 
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/audio/alert.mp3" (24.3 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-chw-selected.svg" (1.64 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-chw.svg" (1.36 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-nurse-selected.svg" (1.81 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-nurse.svg" (1.83 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-pregnant-selected.svg" (1.51 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon-pregnant.svg" (1.53 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/icon.png" (6.89 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/layers.png" (546 B)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/img/setup-wizard-demo.png" (25.3 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/manifest.json" (323 B)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/enketo-icons-v2.woff" (3.27 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/NotoSans-Bold.ttf" (415 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/fonts/NotoSans-Regular.ttf" (415 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/src/public/login/script.js" (6.03 kB)
Caching static resource "/home/cliff/Documents/project/medic/cht-core/api/src/public/login/style.css" (2.74 kB)
/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html was listed as a dependency for dynamic URL /, but the file does not exist. Either remove the entry as a dependency, or correct the path to the file.
2022-06-20 19:58:53 ERROR: Fatal error initialising medic-api 
2022-06-20 19:58:53 ERROR: { Error: ENOENT: no such file or directory, stat '/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html'
    at Object.statSync (fs.js:855:3)
    at getFileAndSizeAndHashForFile (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:40:17)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:214:22
    at Array.map (<anonymous>)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:212:12
    at Array.forEach (<anonymous>)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:194:50
    at new Promise (<anonymous>)
    at generate (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:128:10)
    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:346:5
  [stack]:
   'Error: ENOENT: no such file or directory, stat \'/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html\'\n    at Object.statSync (fs.js:855:3)\n    at getFileAndSizeAndHashForFile (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:40:17)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:214:22\n    at Array.map (<anonymous>)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:212:12\n    at Array.forEach (<anonymous>)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:194:50\n    at new Promise (<anonymous>)\n    at generate (/home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:128:10)\n    at /home/cliff/Documents/project/medic/cht-core/api/node_modules/sw-precache/lib/sw-precache.js:346:5',
  [message]:
   'ENOENT: no such file or directory, stat \'/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html\'',
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path:
   '/home/cliff/Documents/project/medic/cht-core/api/extracted-resources/index.html' } 
[nodemon] app crashed - waiting for file changes before starting...

thanks @diana ,i have added the api logs above

Thanks @cliff.
Can you please tell me which version of CHT are you trying to start? It looks like the index.html file is missing from the ddoc.

"name": "medic",
  "version": "3.15.0",
  "private": true,
  "license": "AGPL-3.0-only",
  "repository": {
    "type": "git",
    "url": "git://github.com/medic/cht-core.git"
  },

@diana its 3.15 according to the root package.json file

Are you making any changes to the source code? Or installing directly?
I’m checking the release document and it does contain that missing file.

yes i am only trying to add the css style to the reports-content-component

Then I’m guessing you have an issue with building webapp. you could try retracing your steps and building webapp after every change.

1 Like

hello @diana ,while building webbapp with grunt i get

Running "exec:build-webapp" (exec) task
Node.js version v10.24.1 detected.
The Angular CLI requires a minimum Node.js version of either v12.14 or v14.15.

Please update your Node.js version or visit https://nodejs.org/ for additional instructions.

>> Exited with code: 3.
>> Error executing child process: Error: Process exited with code 3.
Warning: Task "exec:build-webapp" failed. Use --force to continue.

Aborted due to warnings.


Execution Time (2022-06-22 09:48:05 UTC+3)
exec:npm-ci-shared-libs  47.5s  β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡ 72%
exec:npm-ci-modules      16.9s  β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡ 26%
Total 1m 5.5s

cliff@cliff-Latitude-5580:~/Documents/project/medic/cht-core$

but i have used nvm to switch to node v12.14 as seen below in the screenshot
Screenshot from 2022-06-22 10-45-19
Not sure why the the grunt build of the webbapp still detects v10.24 and ends failing the build

Hi @cliff. You have to run the nvm use command in the terminal where you’re actually running the grunt command.

2 Likes

thanks @diana works fine now