How to use nodemon with .env files?

后端 未结 11 1060
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 02:37

I am using an .env file to hold environment variables for the server. This works if I run the server with foreman start. But it doesn\'t work with nodemon.

I would

11条回答
  •  猫巷女王i
    2020-12-09 02:59

    You can get nodemon to directly use the .env with the following command

    $: env $(cat .env) nodemon app.js
    

    Be aware that you'll have to restart it if you make changes to .env and it won't like it if there are any spaces in your .env file.

提交回复
热议问题