It looks like the process.env.MONGO_CONNECTION_URL is not a string.
Typically, when this happens, your environment variable is undefined.
There are two common places you set your environment variables:
Inside a configuration file
Inside a script in the package.json file
Based on the error, if the environment variable is not a string, it is likely undefined. If you are setting the environment variable with one of the two methods listed above, be sure it is a string.
Otherwise, you may not be setting it at all, and in this case, set it in one of those two ways.
2
Answers
It looks like the
process.env.MONGO_CONNECTION_URL
is not a string.Typically, when this happens, your environment variable is undefined.
There are two common places you set your environment variables:
package.json
fileBased on the error, if the environment variable is not a string, it is likely undefined. If you are setting the environment variable with one of the two methods listed above, be sure it is a string.
Otherwise, you may not be setting it at all, and in this case, set it in one of those two ways.
You should setup
dotenv
to read env vars (assuming they are insample.env
):You can install the package with: