Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Passing port number to start script #10

Open
geekman-rohit opened this issue Jun 29, 2015 · 4 comments
Open

Passing port number to start script #10

geekman-rohit opened this issue Jun 29, 2015 · 4 comments

Comments

@geekman-rohit
Copy link
Contributor

We have multiple options here :

  1. Pass as parameter to the script (e.g. node index.js 8080)
  2. Write in the config file. (We will have a config.json file for the database configs anyways)

I am more inclined towards the second option, of passing via config file. Any opinions?

@jzaefferer
Copy link

You should use the config key in package.json, which you can then override with a .npmrc file:

{
  "name": "chassis-themeroller",
  ...
  "config": {
    "port": 8080
  }
}

To override in .npmrc:

chassis-themeroller:port=5000

In your app, access the config as an env var:

var port = process.env.npm_package_config_port

You can use that for all configuration, including the database. Then start app with npm start (and the appropriate start script in package.json).

@arthurvr
Copy link

That's how I was thinking as well, +1 to what @jzaefferer said.

@geekman-rohit
Copy link
Contributor Author

@jzaefferer , that sounds better to me too, one query though about saving database config, we could have it directly in .npmrc file? or we should have it in config in package.json too?

@jzaefferer
Copy link

See also my comment in #11.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants