'Resolve parent path in npm script to set node environmet variable
I'm trying to resolve a parent path in a npm script to set a node environment variable.
So, given this folder strucure
I need to access paas folder from src to get configuration.yml path.
My index.js is currently setting this variable value like so.
index.js
process.env.CONFIG_FILE_PATH = path.resolve(process.cwd(), '../paas/configmap.yml');
and the value is setted to something like C:/my-user/projects/project-name/paas/configuration.yml (using windows)
What I need is to remove that code from index.js, as this variable is only needed when I run the project locally, and move it to a npm script to set the variable value dynamically.
package.json
{
"scripts" : {
"start" : cross-env CONFIG_FILE_PATH=resolve.configuration.path node index.js
}
}
Is there any way (windows or cross env) to achieve the same result as path.resolve, straight in a npm script?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

