'Getting an error when starting express server
I'm trying to run a typescript/express server (which also has prisma), and have different environment variables for different environments. I'm using dotenv-cli, so that the correct env file can run on a command line level (because of prisma), when I run the following command:
dotenv -e .env.development -- nodemon src/index
I get the following error:
Traceback (most recent call last):
4: from /usr/local/bin/dotenv:23:in `<main>'
3: from /usr/local/bin/dotenv:23:in `load'
2: from /Library/Ruby/Gems/2.6.0/gems/dotenv-2.7.6/bin/dotenv:4:in `<top (required)>'
1: from /Library/Ruby/Gems/2.6.0/gems/dotenv-2.7.6/lib/dotenv/cli.rb:18:in `run'
/Library/Ruby/Gems/2.6.0/gems/dotenv-2.7.6/lib/dotenv/cli.rb:34:in `parse_argv!': invalid option: e (OptionParser::InvalidOption)
4: from /usr/local/bin/dotenv:23:in `<main>'
3: from /usr/local/bin/dotenv:23:in `load'
2: from /Library/Ruby/Gems/2.6.0/gems/dotenv-2.7.6/bin/dotenv:4:in `<top (required)>'
1: from /Library/Ruby/Gems/2.6.0/gems/dotenv-2.7.6/lib/dotenv/cli.rb:18:in `run'
/Library/Ruby/Gems/2.6.0/gems/dotenv-2.7.6/lib/dotenv/cli.rb:34:in `parse_argv!': invalid option: -e (OptionParser::InvalidOption)
How can I run dotenv-cli with typescript files and watch the files for changes?
Solution 1:[1]
It looks like your ruby dotenv is taking precedence over the node dotenv-cli
Try this instead:
npx dotenv-cli -e .env.development -- nodemon src/index
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | simj |
