You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the mongo.js file, two environment variables are defined: $MONGO_DATABASE and $MONGO_CONN_STR.
When creating the .env file, if the $ character is used to name the variables, the dotenv and sugar-env libraries won't be able to locate them. As a result, the connection to the database won't be established.
Variable names in .env files should not start with the $ character, as this is not in line with best practices. Therefore, when using MongoDB, in addition to creating the .env file with the variables and their values, it's also necessary to edit the mongo.js file to remove the $ character.
Steps to Reproduce
Create a new project as shown below:
Example of generated mongo.js file
Suggested correction:
Remove the $ character from the variables in the mongo.ejs template file.
Implement the automatic creation of the .env file, which by default can contain the same fallback values for their respective variables (similar to what's done in mongo.ejs), as shown in the example below:
This will ensure that the variable names comply with naming guidelines and that the libraries can properly load the environment variables. Additionally, the automatic creation of the .env file will streamline the configuration process.
The text was updated successfully, but these errors were encountered:
Problem Description
In the mongo.js file, two environment variables are defined: $MONGO_DATABASE and $MONGO_CONN_STR.
When creating the .env file, if the $ character is used to name the variables, the dotenv and sugar-env libraries won't be able to locate them. As a result, the connection to the database won't be established.
Variable names in .env files should not start with the $ character, as this is not in line with best practices. Therefore, when using MongoDB, in addition to creating the .env file with the variables and their values, it's also necessary to edit the mongo.js file to remove the $ character.
Steps to Reproduce
Create a new project as shown below:
Example of generated mongo.js file
Suggested correction:
Remove the $ character from the variables in the mongo.ejs template file.
Implement the automatic creation of the .env file, which by default can contain the same fallback values for their respective variables (similar to what's done in mongo.ejs), as shown in the example below:
.env
MONGO_DATABASE='<%- props.dbName %>'
MONGO_CONN_STR=mongodb://localhost:27017
This will ensure that the variable names comply with naming guidelines and that the libraries can properly load the environment variables. Additionally, the automatic creation of the .env file will streamline the configuration process.
The text was updated successfully, but these errors were encountered: