Error: Cannot find module '@medic/contact-types-utils'

I’m trying to run “node server.js” in my cht project/api but I got error:
ERROR: Reason: Error: Cannot find module ‘@medic/contact-types-utils’.
I ran the command “npm install @medic/contact-types-utils” but could not find this module.
Can I find this module elsewhere?

Can you please make sure that you run grunt before trying to start the API server?
That makes sure that all dependencies are installed in all modules (including API).

Yes I run it before. all I get is:

I’ve also run all the commands suggested in the attached image before

Can you please try using Node v max 12 and npm max 6?
Also please make sure that no edits have been made to any package.json or package-lock.json files.

thank you @diana,
I installed node v12.13.0 and npm v6.12.0. It’s still the same problem. I will change the operating system and try again. Currently I am on windows, maybe the problem comes from that. I will switch to Ubuntu and let you know if the problem persists or not

I have the same problem with another system.
I am trying to install this package manually by running npm install @medic/contact-types-utils but the package is not found as shown in the picture.

@medic/contact-types-utils is pushed to npm, it’s a local dependency: cht-core/shared-libs/contact-types-utils at master · medic/cht-core · GitHub

We create symbolic links to local dependencies after running npm ci, because npm <= 6 doesn’t resolve local paths very well.
Once we switch to npm 8 (next year?), we will be able to just use local paths and depend on npm resolving them correctly.
Until then, please have a look at what we do in the Gruntfile.js to figure out where the failure comes from.

We don’t support Windows. Please have a look at our supported systems.

I don’t know what happens every time I run grunt. Now I am seeing this error despite all attempts to install this package, it doesn’t work.
I don’t know if I missed anything. here are my steps:

  • git clone
  • I installed npm v6 and node v12.x
  • cd cht-core
  • npm ci
  • grunt

  • my operating system is Ubuntu 20.04.3 LTS

The last error looks like you’re missing some dependencies of grunt.

Can you please make sure you installed grunt cli as per the development instructions: cht-core/ at master · medic/cht-core · GitHub?

now it works but only with node v14.18.1 and npm v6.14.15. I will continue to check why it refuses other versions of node. maybe the problem is with the recent version of ubuntu. I’ll let you know if I find the problem

Hello @kossi @diana
i am facing the issue of not finding @medic/contact-types-utils surprisingly with node v14.18.1 and npm v6.14.15 . on ubuntu 20.10
I have run grunt in the root folder with
COUCH_URL=http://myadminuser:myadminpass@localhost:5984/medic COUCH_NODE_NAME=nonode@nohost grunt but i get Running "exec:undo-patches" (exec) taskModule restored: bootstrap-daterangepic -

have been managed to get @medic/contact-types-utils to be tracked ,had to run npm ci & and also did an npm upgrade .

However the node server.js or grunt dev-api in core/api folder fails to initilaze the api servrer with

2021-11-29 14:16:01 INFO: Running server checks… 
Node Environment Options: 'undefined'
Node Version: 14.18.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
2021-11-29 14:16:01 INFO: Checks passed successfully 
2021-11-29 14:16:01 INFO: Extracting ddoc… 
2021-11-29 14:16:01 ERROR: Fatal error initialising medic-api 
2021-11-29 14:16:01 ERROR: {
  error: 'not_found',
  reason: 'missing',
  status: 404,
  name: 'not_found',
  message: 'missing',
  docId: '_design/medic'

Any ideas on initialization on the medic-api is failling ?
i have looked into this similar reference but am using ubuntu
@marc @gareth

Hi @cliff

_design/medic is the main design document that the app uses and is required for API to start up. It is built and uploaded as part of the grunt command. Has your grunt command finished successfully?

You should see something like:

Running "couch-push:localhost" (couch-push) task
Get revisions http://localhost:5984/medic...OK
Pushing http://localhost:5984/medic...OK
>> 1 database deployed

Running "notify:deployed" (notify) task

when i run grunt with COUCH_URL=http://myadminuser:myadminpass@localhost:5984/medic COUCH_NODE_NAME=nonode@nohost grunt i get this funny response liff@cliff-Latitude-5580:~/Documents/project/cht-core$ COUCH_URL=http://myadminu -

yet i have grunt installed globally with sudo npm install -g grunt-cli

> cliff@cliff-Latitude-5580:~/Documents/project/cht-core$ grunt --version 
> grunt-cli v1.4.3
> cliff@cliff-Latitude-5580:~/Documents/project/cht-core$

Hi @cliff

The problem you are seeing should not exist in any released version of the CHT and it’s something that we fixed earlier this year: Form validation throw exception when medic-conf has --archive attibute · Issue #396 · medic/cht-conf · GitHub

You mentioned upgrading packages? Can you please check which version of medic-conf you have installed in your cht-core directory?

thanks @diana for the timely feedback

yeah i did an npm upgrade

its "medic-conf": "^3.6.0", in my package.json file

Please revert the upgrade of all packages and try again.