Yeoman 'grunt test' fails on clean project

2019-06-17 01:29发布

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
  • generator-angular@0.3.0

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.

3条回答
Explosion°爆炸
2楼-- · 2019-06-17 01:38

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.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-06-17 01:44

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
    }
  }
}
查看更多
戒情不戒烟
4楼-- · 2019-06-17 02:02

Add port: 9001 to test, like this:

test: {
  options: {
    port: 9001,
    ...
  }
}
查看更多
登录 后发表回答