COUCH_URL isn't defined error, when running npm run build-dev-watch

cc @jkuester
issue link: `COUCH_URL` isn't defined error, when running `npm run build-dev-watch` · Issue #9932 · medic/cht-core · GitHub

for the workaround I had to hardcode COUCH_URL in my local setup.

What do you mean by “hardcode”? As noted in the dev environment setup docs this environment variable will be needed for running many (most?) of the cht-core npm scripts and it is recommended to permanently define the variable for your shell (e.g. in the .bashrc file).

When running this command npm run build-dev-watch, I was seeing the above error which is mentioned in Error so I had to hardcode the value of COUCH_URL in cht-core/scripts/build/index.js file.

Have you added the variable in the shell config file?

Can you confirm it by running: echo $COUCH_NODE_NAME && echo $COUCH_URL?

Hey @Sujal it has already been added

:thinking: It seems like there is some disconnect between the envars in your local environment and what is being loaded when running node.

The scripts/build/index.js script should load the COUCH_URL value from the shell environment in context for the node/npm command. Can you share more details about your development environment?

  • What is your OS?
  • Are you running it in a VM?
  • How did you install node?
  • What shell are you using? (e.g. bash)

Can you try running just the node command to pop into a NodeJS shell. Then, in the shell run console.log(process.env.COUCH_URL);. What is the output? E.g. for me this looks like:

❯ node
Welcome to Node.js v22.14.0.
Type ".help" for more information.
> console.log(process.env.COUCH_URL);
http://medic:password@localhost:5984/medic
2 Likes