Fake-cht permission errors when running watchdog in dev mode

I’m trying to follow these steps to run CHT Watchdog in develop mode.

I’m executing

docker compose -f docker-compose.yml -f exporters/postgres/docker-compose.postgres-exporter.yml -f development/fake-cht/docker-compose.fake-cht.yml up -d

This results in these npm permission errors

cht-watchdog-fake-cht-1           | npm ERR! code EACCES
cht-watchdog-fake-cht-1           | npm ERR! syscall mkdir
cht-watchdog-fake-cht-1           | npm ERR! path /home/node/app/node_modules
cht-watchdog-fake-cht-1           | npm ERR! errno -13
cht-watchdog-fake-cht-1           | npm ERR! Error: EACCES: permission denied, mkdir '/home/node/app/node_modules'
cht-watchdog-fake-cht-1           | npm ERR!  [Error: EACCES: permission denied, mkdir '/home/node/app/node_modules'] {
cht-watchdog-fake-cht-1           | npm ERR!   errno: -13,
cht-watchdog-fake-cht-1           | npm ERR!   code: 'EACCES',
cht-watchdog-fake-cht-1           | npm ERR!   syscall: 'mkdir',
cht-watchdog-fake-cht-1           | npm ERR!   path: '/home/node/app/node_modules'
cht-watchdog-fake-cht-1           | npm ERR! }
cht-watchdog-fake-cht-1           | npm ERR! 
cht-watchdog-fake-cht-1           | npm ERR! The operation was rejected by your operating system.
cht-watchdog-fake-cht-1           | npm ERR! It is likely you do not have the permissions to access this file as the current user
cht-watchdog-fake-cht-1           | npm ERR! 
cht-watchdog-fake-cht-1           | npm ERR! If you believe this might be a permissions issue, please double-check the
cht-watchdog-fake-cht-1           | npm ERR! permissions of the file and its containing directories, or try running
cht-watchdog-fake-cht-1           | npm ERR! the command again as root/Administrator.
cht-watchdog-fake-cht-1           | 
cht-watchdog-fake-cht-1           | npm ERR! A complete log of this run can be found in: /home/node/.npm/_logs/2023-07-18T07_31_00_770Z-debug-0.log

I can resolve these issues by removing the line user: "node" in the development/fake-cht/docker-compose.fake-cht.yml. I ran rm -Rf development/fake-cht/node_modules to ensure this folder is empty.

Did I miss a step? Something missing in the docs? Bug? Welcome any and all thoughts. cc @jkuester

Thanks for raising this @kenn! Mrjones ran into this same issue and it turned out to be an issue with the file permissions of resources in development/fake-cht. Running this should fix it:

chmod 777 development/fake-cht/package*
chmod 777 development/fake-cht/last-response.json

BEFORE YOU DO THAT, could you possibly note what the previous permissions were for those files? I am trying to understand the sequence of steps that results in this behavior (so we can maybe prevent it in the future).

Ok. I will run the chmod commands.

-rw-r--r--  1 kenn kenn  1720 Jul 18 01:06 last-response.json
drwxr-xr-x 81 kenn kenn  4096 Jul 18 01:07 node_modules
-rw-rw-r--  1 kenn kenn   149 Jul 18 01:28 package.json
-rw-rw-r--  1 kenn kenn 49361 Jul 18 01:28 package-lock.json