React import based on node variable

I am trying to figure this out an have not found anything helpful yet.

The idea is that in certain components or files I need to import a specific file based on the node variable.

Some example scripts that will be run include:

USER=test yarn run build //or
USER=test yarn run serve

Now depending on the USER variable I need to do imports like

import `~/users/${process.env.USER}/config.json`;

This obviously doesn’t worked and I am confused on how to get this to work. Surely there is a way to base imports on a node variable and then import from different folders and files based on that. Any help or links would be greatly appreciated!

React import based on node variable