Hello Team,
I have created Adobe IO runtime project and trying to run in my local system. But, my logic is not picking the environment specific details.
Here is the .env file data
AIO_RUNTIME_AUTH=12345678
AIO_RUNTIME_NAMESPACE=123456-poc-testing
NODE_ENV=development
My node js file has
// Import the dotenv package to load environment variables
import dotenv from 'dotenv';
dotenv.config();
// Import default configuration
import defaultConfig from './default.js';
// Dynamically import the environment-specific configuration
const env = process.env.NODE_ENV || 'development';
console.log("end file is:",env,process.env.NODE_ENV);
const envConfigModule = await import(`./${env}.js`);
return envConfigModule.default;
// Export a function to get the merged configuration
const envConfig = await loadEnvConfig();
console.log("defaultConfig",defaultConfig)
return { ...defaultConfig, ...envConfig };
Here, instead of giving the data from development.js file, I am getting the value for production.js file
console.log("end file is:",env,process.env.NODE_ENV); This line gives me production.
Thanks in advance.
cc @AMANATH_ULLAH @sarav_prakash @mk_aem21 @arunpatidar @AmitVishwakarma
Views
Replies
Total Likes
To read the namespace you can use below environment variable
process.env.__OW_NAMESPACE
https://developer.adobe.com/runtime/docs/guides/reference/environment_variables/
You dont need dotenv from node20.6.0. Read here. https://nodejs.org/en/blog/release/v20.6.0#notable-changes
So to fix,
"engines": {
"node": "20.11.0"
},
import dotenv from 'dotenv'; dotenv.config();
Another note: Even if you create .env.prod and .env.dev, when deploying you manually need to copy .env.dev into .env during dev deploy and similar for prod. Instead setup CD using github actions and populate .env using github secrets. Thereby deployment pipeline will automatically populate right secrets.
I am guessing, when you are deploying into dev, your .env is having .env.prod values. Thats why you see incorrect. Ensure your .env is populated correctly during dev deploy.
Thanks @sarav_prakash for your help.
Now, my package.json file has this details:
Views
Replies
Total Likes
preferably use single node version as
@Mahesh_Gunaje Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies