Private npm package is picking up old value for config variable even after mutating it - express

I am using node-config in my express.js project. In the test file, I mutated the value for a test config variable. It is getting changed successfully as it is returning new value on logging it in the test file. But my private npm package which is using the config variable still picks up the old value. The package picks up the values of config variables at the time of build of the project only. Changing of config variables after that does not affect the already picked-up config values by package. So, how to reflect the changed values in the package?

Related

Apply IntelliJ run configuration template changes to all existing configurations

Often I have to update the env variables on my run configuration templates. The problem is that I also have to go and update all existing run configurations with the updated env variables. Is there a way to apply run configuration template changes to all existing run configuration that match that template?

How update properly VueJs .env files

Getting old value still after updating with the fresh new values
VUE_APP_API_URL="http://example.com/api/"
Is there a command to clear the cache?
I have event build my project again... :(

Vue.js: To Get Environment Variables in js File

I have created .env file to set environment variables as shown below:
Inside which I have given below mentioned code.
VUE_APP_BASEURL="https://qa-apps-nodejs.Dtech.com:9000/"
PORT=8080
I have written below code in my js file and executed npm install dotenv:
require('dotenv').config();
console.log(process.env.VUE_APP_BASEURL);
With the above code, I need to get https://qa-apps-nodejs.Dtech.com:9000/ in console. But instead I'm getting:
undefined
Just restart your server as newly created env variables are not available only after hot-reload you have to rebuild your application (restart your server). For reference you can look here
No need to install "dotenv" simply place .env file in the root of your project (at the same level of your package.json file) and Vue CLI will handle the reset. Side note; as of Vue CLI 3 only variables that start with VUE_APP_ will be loaded. make sure also to rerun npm run serve again to restart your server.
for more details: visit docs

Is there any way to add environment variables to a npm package and modify it in azure build pipeline?

I've created one npm package which accesses few API's running in the backend. The URL to access those api's are hardcoded in the package. Most of the times we need to change the URL to point to some another api (different version pointing different database). And we end up editing the code and update the URL and re-publish the npm package.
Our npm package code is in a private git repo. We are creating a pipeline which will auto-publish the package on check-in. We want to add the URL's as build variables which will be fetched during build pipeline and will be added as part of npm package before publishing.
Is there any way to do so? If yes what changes needs to be done in the azure pipeline process and in the actual code?
As what you said, you store your npm package code in Repos. Here I think the Replace Token task can for you to achieve replacing the URL from variable into your code.
To use that task:
(1). you need firstly store URLs into variables. For example, create one variable names A and input the value.
(2). Then follow that task syntax(#{****}#) to modify your code.
Go the script where you want it to be replaced with the variables
value. Modify it as #{A}# . (Here please make sure the **** value
is same with the relevant variables name you configured before.)
Thus the corresponding location can be replaced by the variables
value automatically during the build.
For detailed steps, you can refer my previous answer which has the similar demands.
Another things you need pay attention to is (3). add this Replace token task before your package publish step. After you check in the code and trigger the build, it will firstly override the source code by replacing the variable value into script. Then the next publish step could pack and publish a completed source files with these changed codes.

Adding variables in AndroidManifest.xml, MainActivity.java and MainApplication.java in React Native

Is there a way to pass variables to AndroidManifest.xml, MainActivity.java and MainApplication.java?
I am planning to change the bundleId based on the environment I am running ex.: (com.app.dev and com.app.prod).
Right now I can easily pass variables to AndroidManifest.xml to change the app label, version code, version name and so on except the package name. Whenever I pass the variable "${bundleId}", it does not read the value inside the variable instead it reads the variable itself which is "${bundleId}" so it gives me an error.
Or is there any way on how to do environment setting on AndroidManifest.xml, MainActivity.java and MainApplication.java?
I sorted it out in a much easier way.
I created a folder called dev and prod
Inside these folders are the xml and java files that contains bundle ID or package ID for each environment.
I created a bash script that will copy and paste the AndroidManifest.xml, MainActivity.java and MainApplication.java files from dev or prod folder to /android/app/src/main/... when I run the app.
I worked well :)
Case closed