Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在代码里面使用 require('runkoa')(__dirname + '/app.js' ) 有时会有错误! #5

Closed
k-dylan opened this issue Apr 16, 2016 · 2 comments

Comments

@k-dylan
Copy link

k-dylan commented Apr 16, 2016

您好!很感谢您开发了runkoa,可以让我们这些新手很方便的使用koa2+async组合,但是在使用的过程中,出现一个问题,我是初学koa,在bin/www中使用 require('runkoa')(__dirname + '/app.js' )调用app.js的时候,发现每次都不会执行app.js,最后发现在index.js代码中有这么一句:

var f = current_path + '/bin/www'

  if (is_cli == true && entry && /^\//.test(entry)){
    f = entry
  }

也就是说如果不是直接在命令行执行,那么f的指向的文件都会是bin/www,所以每次都无法执行app.js。

不知道这是您专门这么写的,还是一个失误呢?

我也是初学node,如有不当之处 还望指正! 谢谢

@i5ting
Copy link
Collaborator

i5ting commented Apr 17, 2016

感觉是你用的不太对吧,参见https://github.com/17koa/koa2-demo/tree/master/bin

如果是app.js里直接listen端口,也可以直接require('runkoa')(__dirname + '/app.js' )

@k-dylan
Copy link
Author

k-dylan commented Apr 18, 2016

感谢提醒,我刚又测试了一下,是我的失误,应该是上次没有在app.js里面listen端口,检查代码的时候又不仔细,没看清最后 require 的是 entry

@k-dylan k-dylan closed this as completed Apr 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants