2

I am using an .env file to work with foreman, but am trying to configure nodemon to start my server using grunt, because I enjoy how nodemon restarts when files become modified.

I am trying avoid having an .env file for foreman AND having environment variables stored in my ~/.bash_profile for nodemon. Instead, I would like to configure my .env file to work for both cases.

I found some answers here, and the second answer should work for grunt.

My .env file is of JSON format, which should flatten environment variables via concatenation (see here).

When I run the following command $ env $(cat .env) nodemon app.js, I receive the following error: env: {: No such file or directory.

Anyone have an idea of what the problem may be? Cheers.

Community
  • 1
  • 1
user3033477
  • 21
  • 1
  • 3

2 Answers2

2

I'd suggest filing this at http://github.com/remy/nodemon/issues/new - but I'd also say that there's environment config support in nodemon as of 1.0.9 - though I'm not 100% sure it'll solve what you want.

Basically you put a nodemon.json file in your home directory, and have:

{
  "env": {
    "USER": "remy",
    "PORT": "8000",
    "ETC": "etc"
  }
}

An example of the config can be seen here and a few more details here.

Remy Sharp
  • 4,520
  • 3
  • 23
  • 40
0

I haven't tried using the nodemon. But I've figured out how to do restart the server using foreman.

Define a key on your Procfile to run your application with node-supervisor

My proc file have a dev key that is like this: dev: node-supervisor -w .,lib/ webserver.js

The -w option is a comma separated list of the folders that you want to watch.