Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yeoman 'grunt test' fails on clean project with 'port already in use'

With:

  • Mac OS 10.8.4
  • Node 0.10.12
  • npm 1.3.1
  • grunt-cli 0.1.9
  • yo 1.0.0-rc.1
  • bower 0.9.2
  • [email protected]

I encounter the following error with a clean yo angular project, followed by grunt server then grunt test:

Running "connect:test" (connect) task  
Fatal error: Port 9000 is already in use by another process.

I'm new to Yeoman and am stumped. I've deleted my original project and created a new one in a fresh folder just to make sure I wasn't overlooking any invisible configs. I restarted the machine to make sure I wasn't running any temporary server processes I had forgotten about. After all attempts, the basic server starts fine, attaches to Chrome, and the watcher updates the browser on any changes. (Notably, the server is running on 9000, which seems odd for the test-runner to also be trying to use 9000.) But I get that same error on attempting to start the test runner.

Is this something I can fix, or an issue I should report to the Yeoman team? Thanks.

like image 534
XML Avatar asked Jul 01 '13 02:07

XML


3 Answers

Add port: 9001 to test, like this:

test: {
  options: {
    port: 9001,
    ...
  }
}
like image 197
Ching-Han Ho Avatar answered Jan 04 '23 12:01

Ching-Han Ho


I created a new config property: connect.test.options.port, and set that to 9001. Now they appear to be running properly on separate ports.

Note also that the Gruntfile.js is overriding the singleRun property in karma.conf.js. Comment/cut that out if you want the config in karma.conf.js to work properly.

EDIT 11/4/13: The issue was reported by others as well and seems to have been addressed with changes to generator-angular.

like image 33
XML Avatar answered Jan 04 '23 14:01

XML


After I change the port, there is a XHR error, The 'Access-Control-Allow-Origin' header has a value 'http://localhost:9000' that is not equal to the supplied origin. Origin 'http://localhost:9090' is therefore not allowed access. It was 9000 initially and then I change the grunt

connect: {
  main: {
    options: {
      port: 9090
    }
  }
}
like image 30
thisarattr Avatar answered Jan 04 '23 14:01

thisarattr