18

I'm sure I remember seeing some documentation somewhere that had a way to save the port number ember-cli uses in a config file, but it doesn't seem to say anything in the documentation.

I have to use

ember server --port 9999

but i would love to save that port number in a file.

real_ate
  • 10,861
  • 3
  • 27
  • 48
  • I use an alias, easier to do and remember. – givanse Jun 04 '14 at 06:06
  • Again that's harder to share with your team. I'm looking to simplify the process so that there are as few barriers for the team adopting this as possible – real_ate Jun 04 '14 at 12:42
  • And also we currently have about 3-4 different ember apps (hence why we need different ports) so having an alias doesn't work here – real_ate Jun 04 '14 at 12:42

3 Answers3

28

You can use a .ember-cli config file to change the port. discussion

So in your root folder, have a .ember-cli file with the following:

{
  "port": 9999
}

Edit: the .ember-cli file is now documented on the ember-cli website.

David Rice
  • 1,111
  • 1
  • 11
  • 24
  • Although, it seems to be broken in the latest version. https://github.com/stefanpenner/ember-cli/issues/1080 – David Rice Jun 30 '14 at 17:14
  • update: The fix has been merged into master, so should be in v0.0.41 if you don't want to deal with #latest – David Rice Aug 20 '14 at 02:39
3

Using a .ember-cli file is the way to go according to the ember-cli docs here.

I'm using nitrous.io - which is fantastic - however it doesn't allow port 4200 - and in any case I wanted the server to be on 3000.

Also, I noticed that the server was starting up and refreshing very slowly - issue seems to be with the live-reload-server - and again the default port.

So, my .ember-cli config file now looks like this...

{
    "port": 3000,
    "live-reload-port": 4000
}

Everything seems ok with nitrous.io and most importantly my server load time is now what you would expect - also, live-reload works great.

0

I'm not sure if this is the proper place to change it, but changing node_modules/ember-cli/lib/commands/serve.js

{ name: 'port', type: Number, default: 4200 },

to

{ name: 'port', type: Number, default: 9999 },

seems to do it.

theBernd
  • 191
  • 1
  • 7
  • 1
    The problem with that one is that whenever you update ember-cli it will override it, and you can't share that config with your team to make sure it is proxies by nginx correctly etc. – real_ate Jun 04 '14 at 12:36