egg icon indicating copy to clipboard operation
egg copied to clipboard

egg+ts项目用npm run start启动不报错,访问报500

Open jiaotashidi opened this issue 7 years ago • 27 comments

What happens?

最小可复现仓库

请使用 npm init egg --type=simple bug 创建,并上传到你的 GitHub 仓库

复现步骤,错误日志以及相关配置

相关环境信息

  • 操作系统:
  • Node 版本:
  • Egg 版本:

jiaotashidi avatar Sep 04 '19 07:09 jiaotashidi

##1 npm run dev正常启动且可以正常访问 npm run start-test启动控制台不报错,浏览器访问时报500 script配置如下:

"scripts": {
    "start": "egg-scripts start --port=7002 --env=prod --workers=3 --daemon --title=egg-server-ts",
    "start-test": "egg-scripts start --port=7002 --env=test --workers=3 --daemon --title=egg-server-ts",
    "stop": "egg-scripts stop --title=egg-server-ts",
    "dev": "egg-bin dev --port=7002",
    "debug": "egg-bin debug",
    "test-local": "egg-bin test",
    "test": "npm run lint -- --fix && npm run test-local",
    "cov": "egg-bin cov",
    "tsc": "ets && tsc -p tsconfig.json",
    "ci": "npm run lint && npm run cov && npm run tsc",
    "autod": "autod",
    "lint": "tslint --project . -c tslint.json",
    "clean": "ets clean"
  }

2. npm run test-start 控制台输出如下:

npm run start-test

> [email protected] start-test e:\code\ai-weekly
> egg-scripts start --port=7002 --env=test --workers=3 --daemon --title=egg-server-ts

[egg-scripts] Starting egg application at e:\code\ai-weekly
[egg-scripts] Run node --require e:\code\ai-weekly\node_modules\source-map-support\register.js e:\code\ai-weekly\node_modules\egg-scripts\lib\start-cluster {"port":7002,"workers":3,"title":"egg-server-ts","baseDir":"e:\\code\\ai-weekly","framework":"e:\\code\\ai-weekly\\node_modules\\egg"} --title=egg-server-ts
[egg-scripts] Save log file to C:\Users\XXX\logs
[egg-scripts] Wait Start: 1...
[egg-scripts] Wait Start: 2...
[egg-scripts] egg started on http://127.0.0.1:7002

3.浏览器打开 http://127.0.0.1:7002

提示:Internal Server Error, real status: 500

jiaotashidi avatar Sep 04 '19 07:09 jiaotashidi

4. 查看日志 C:\Users\XXX\logs

2019-09-04 15:13:00,499 INFO 9532 [master] =================== egg start =====================
2019-09-04 15:13:00,501 INFO 9532 [master] node version v10.15.0
2019-09-04 15:13:00,501 INFO 9532 [master] egg version 2.23.0
2019-09-04 15:13:00,501 INFO 9532 [master] start with options:
{
  "framework": "e:\\code\\ai-weekly\\node_modules\\egg",
  "baseDir": "e:\\code\\ai-weekly",
  "port": 7002,
  "workers": 3,
  "plugins": null,
  "https": false,
  "title": "egg-server-ts"
}
2019-09-04 15:13:00,501 INFO 9532 [master] start with env: isProduction: true, EGG_SERVER_ENV: test, NODE_ENV: production
2019-09-04 15:13:00,510 INFO 9532 [master] agent_worker#1:6764 start with clusterPort:52984
2019-09-04 15:13:01,187 INFO 6764 Plugin development is disabled by env unmatched, require env(local) but got env is test
2019-09-04 15:13:01,204 INFO 6764 [egg:core] App root: e:\code\ai-weekly
2019-09-04 15:13:01,204 INFO 6764 [egg:core] All *.log files save on "C:\\Users\\XXX\\logs\\ts"

jiaotashidi avatar Sep 04 '19 07:09 jiaotashidi

node 版本:v10.15.0 操作环境:windows7 egg版本:2.23.0

jiaotashidi avatar Sep 04 '19 07:09 jiaotashidi

2019-09-04 15:13:01,204 INFO 6764 [egg:core] Loaded enabled plugin [{"enable":true,"package":"egg-session","name":"session","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-session","version":"3.1.0"},{"enable":true,"package":"egg-security","name":"security","dependencies":[],"optionalDependencies":["session"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-security","version":"2.6.1"},{"enable":true,"package":"egg-jsonp","name":"jsonp","dependencies":[],"optionalDependencies":["security"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-jsonp","version":"2.0.0"},{"enable":true,"package":"egg-onerror","name":"onerror","dependencies":[],"optionalDependencies":["jsonp"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-onerror","version":"2.1.0"},{"enable":true,"package":"egg-i18n","name":"i18n","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-i18n","version":"2.1.1"},{"enable":true,"package":"egg-watcher","name":"watcher","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-watcher","version":"3.1.0"},{"enable":true,"package":"egg-schedule","name":"schedule","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-schedule","version":"3.6.4"},{"enable":true,"package":"egg-multipart","name":"multipart","dependencies":[],"optionalDependencies":["schedule"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-multipart","version":"2.9.0"},{"enable":true,"package":"egg-logrotator","name":"logrotator","dependencies":["schedule"],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-logrotator","version":"3.1.0"},{"enable":true,"package":"egg-static","name":"static","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-static","version":"2.2.0"},{"enable":true,"package":"egg-view","name":"view","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-view","version":"2.1.2"}]
2019-09-04 15:13:01,305 INFO 6764 [egg:logger] init all loggers with options: {"dir":"C:\\Users\\XXX\\logs\\ts","encoding":"utf8","env":"test","level":"INFO","consoleLevel":"INFO","disableConsoleAfterReady":true,"outputJSON":false,"buffer":true,"appLogName":"ts-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"allowDebugAtProd":false,"type":"agent"}
2019-09-04 15:13:01,316 INFO 6764 [egg:core] dump config after load, 7ms
2019-09-04 15:13:01,346 INFO 6764 [egg-watcher:agent] watcher start success
2019-09-04 15:13:01,346 INFO 6764 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-schedule\agent.js:12:9, remain ["e:\\code\\ai-weekly\\node_modules\\egg-watcher\\lib\\init.js:15:14"]
2019-09-04 15:13:01,346 WARN 6764 [egg-watcher] defaultEventSource watcher will NOT take effect
2019-09-04 15:13:01,346 INFO 6764 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-watcher\lib\init.js:15:14, remain []
2019-09-04 15:13:01,347 INFO 9532 [master] agent_worker#1:6764 started (843ms)
2019-09-04 15:13:01,348 INFO 9532 [master] start appWorker with args ["{\"framework\":\"e:\\\\code\\\\ai-weekly\\\\node_modules\\\\egg\",\"baseDir\":\"e:\\\\code\\\\ai-weekly\",\"port\":7002,\"workers\":3,\"plugins\":null,\"https\":false,\"title\":\"egg-server-ts\",\"clusterPort\":52984}"]
2019-09-04 15:13:01,362 INFO 9532 [master] app_worker#1:8752 start, state: none, current workers: ["1","2","3"]
2019-09-04 15:13:01,362 INFO 9532 [master] app_worker#2:10188 start, state: none, current workers: ["1","2","3"]
2019-09-04 15:13:01,362 INFO 9532 [master] app_worker#3:5232 start, state: none, current workers: ["1","2","3"]

jiaotashidi avatar Sep 04 '19 07:09 jiaotashidi

2019-09-04 15:13:02,038 INFO 10188 Plugin development is disabled by env unmatched, require env(local) but got env is test
2019-09-04 15:13:02,038 INFO 5232 Plugin development is disabled by env unmatched, require env(local) but got env is test
2019-09-04 15:13:02,041 INFO 8752 Plugin development is disabled by env unmatched, require env(local) but got env is test
2019-09-04 15:13:02,059 INFO 10188 [egg:core] App root: e:\code\ai-weekly
2019-09-04 15:13:02,059 INFO 10188 [egg:core] All *.log files save on "C:\\Users\\11091962\\logs\\ts"
2019-09-04 15:13:02,059 INFO 10188 [egg:core] Loaded enabled plugin [{"enable":true,"package":"egg-session","name":"session","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-session","version":"3.1.0"},{"enable":true,"package":"egg-security","name":"security","dependencies":[],"optionalDependencies":["session"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-security","version":"2.6.1"},{"enable":true,"package":"egg-jsonp","name":"jsonp","dependencies":[],"optionalDependencies":["security"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-jsonp","version":"2.0.0"},{"enable":true,"package":"egg-onerror","name":"onerror","dependencies":[],"optionalDependencies":["jsonp"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-onerror","version":"2.1.0"},{"enable":true,"package":"egg-i18n","name":"i18n","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-i18n","version":"2.1.1"},{"enable":true,"package":"egg-watcher","name":"watcher","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-watcher","version":"3.1.0"},{"enable":true,"package":"egg-schedule","name":"schedule","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-schedule","version":"3.6.4"},{"enable":true,"package":"egg-multipart","name":"multipart","dependencies":[],"optionalDependencies":["schedule"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-multipart","version":"2.9.0"},{"enable":true,"package":"egg-logrotator","name":"logrotator","dependencies":["schedule"],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-logrotator","version":"3.1.0"},{"enable":true,"package":"egg-static","name":"static","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-static","version":"2.2.0"},{"enable":true,"package":"egg-view","name":"view","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-view","version":"2.1.2"}]
2019-09-04 15:13:02,061 INFO 5232 [egg:core] App root: e:\code\ai-weekly
2019-09-04 15:13:02,061 INFO 5232 [egg:core] All *.log files save on "C:\\Users\\XXX\\logs\\ts"
2019-09-04 15:13:02,061 INFO 5232 [egg:core] Loaded enabled plugin [{"enable":true,"package":"egg-session","name":"session","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-session","version":"3.1.0"},{"enable":true,"package":"egg-security","name":"security","dependencies":[],"optionalDependencies":["session"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-security","version":"2.6.1"},{"enable":true,"package":"egg-jsonp","name":"jsonp","dependencies":[],"optionalDependencies":["security"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-jsonp","version":"2.0.0"},{"enable":true,"package":"egg-onerror","name":"onerror","dependencies":[],"optionalDependencies":["jsonp"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-onerror","version":"2.1.0"},{"enable":true,"package":"egg-i18n","name":"i18n","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-i18n","version":"2.1.1"},{"enable":true,"package":"egg-watcher","name":"watcher","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-watcher","version":"3.1.0"},{"enable":true,"package":"egg-schedule","name":"schedule","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-schedule","version":"3.6.4"},{"enable":true,"package":"egg-multipart","name":"multipart","dependencies":[],"optionalDependencies":["schedule"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-multipart","version":"2.9.0"},{"enable":true,"package":"egg-logrotator","name":"logrotator","dependencies":["schedule"],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-logrotator","version":"3.1.0"},{"enable":true,"package":"egg-static","name":"static","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-static","version":"2.2.0"},{"enable":true,"package":"egg-view","name":"view","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-view","version":"2.1.2"}]
2019-09-04 15:13:02,065 INFO 8752 [egg:core] App root: e:\code\ai-weekly
2019-09-04 15:13:02,066 INFO 8752 [egg:core] All *.log files save on "C:\\Users\\11091962\\logs\\ts"

jiaotashidi avatar Sep 04 '19 07:09 jiaotashidi

2019-09-04 15:13:02,066 INFO 8752 [egg:core] Loaded enabled plugin [{"enable":true,"package":"egg-session","name":"session","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-session","version":"3.1.0"},{"enable":true,"package":"egg-security","name":"security","dependencies":[],"optionalDependencies":["session"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-security","version":"2.6.1"},{"enable":true,"package":"egg-jsonp","name":"jsonp","dependencies":[],"optionalDependencies":["security"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-jsonp","version":"2.0.0"},{"enable":true,"package":"egg-onerror","name":"onerror","dependencies":[],"optionalDependencies":["jsonp"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-onerror","version":"2.1.0"},{"enable":true,"package":"egg-i18n","name":"i18n","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-i18n","version":"2.1.1"},{"enable":true,"package":"egg-watcher","name":"watcher","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-watcher","version":"3.1.0"},{"enable":true,"package":"egg-schedule","name":"schedule","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-schedule","version":"3.6.4"},{"enable":true,"package":"egg-multipart","name":"multipart","dependencies":[],"optionalDependencies":["schedule"],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-multipart","version":"2.9.0"},{"enable":true,"package":"egg-logrotator","name":"logrotator","dependencies":["schedule"],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-logrotator","version":"3.1.0"},{"enable":true,"package":"egg-static","name":"static","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-static","version":"2.2.0"},{"enable":true,"package":"egg-view","name":"view","dependencies":[],"optionalDependencies":[],"env":[],"from":"e:\\code\\ai-weekly\\node_modules\\egg\\config\\plugin.js","path":"e:\\code\\ai-weekly\\node_modules\\egg-view","version":"2.1.2"}]
2019-09-04 15:13:02,215 INFO 5232 [egg:logger] init all loggers with options: {"dir":"C:\\Users\\11091962\\logs\\ts","encoding":"utf8","env":"test","level":"INFO","consoleLevel":"INFO","disableConsoleAfterReady":true,"outputJSON":false,"buffer":true,"appLogName":"ts-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"allowDebugAtProd":false,"type":"application"}
2019-09-04 15:13:02,216 INFO 8752 [egg:logger] init all loggers with options: {"dir":"C:\\Users\\11091962\\logs\\ts","encoding":"utf8","env":"test","level":"INFO","consoleLevel":"INFO","disableConsoleAfterReady":true,"outputJSON":false,"buffer":true,"appLogName":"ts-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"allowDebugAtProd":false,"type":"application"}
2019-09-04 15:13:02,216 INFO 10188 [egg:logger] init all loggers with options: {"dir":"C:\\Users\\11091962\\logs\\ts","encoding":"utf8","env":"test","level":"INFO","consoleLevel":"INFO","disableConsoleAfterReady":true,"outputJSON":false,"buffer":true,"appLogName":"ts-web.log","coreLogName":"egg-web.log","agentLogName":"egg-agent.log","errorLogName":"common-error.log","coreLogger":{},"allowDebugAtProd":false,"type":"application"}
2019-09-04 15:13:02,243 INFO 10188 [egg-multipart] stream mode enable
2019-09-04 15:13:02,243 INFO 8752 [egg-multipart] stream mode enable
2019-09-04 15:13:02,243 INFO 5232 [egg-multipart] stream mode enable
2019-09-04 15:13:02,306 INFO 10188 Use coreMiddleware order: ["meta","siteFile","notfound","static","bodyParser","overrideMethod","session","securities","i18n"]
2019-09-04 15:13:02,307 INFO 10188 Use appMiddleware order: []
2019-09-04 15:13:02,307 INFO 8752 Use coreMiddleware order: ["meta","siteFile","notfound","static","bodyParser","overrideMethod","session","securities","i18n"]
2019-09-04 15:13:02,307 INFO 8752 Use appMiddleware order: []
2019-09-04 15:13:02,308 INFO 10188 [egg:loader] Use middleware: meta
2019-09-04 15:13:02,308 INFO 10188 [egg:loader] Use middleware: siteFile
2019-09-04 15:13:02,308 INFO 10188 [egg:loader] Use middleware: notfound
2019-09-04 15:13:02,308 INFO 8752 [egg:loader] Use middleware: meta
2019-09-04 15:13:02,308 INFO 8752 [egg:loader] Use middleware: siteFile
2019-09-04 15:13:02,308 INFO 8752 [egg:loader] Use middleware: notfound
2019-09-04 15:13:02,308 INFO 10188 [egg-static] starting static serve /public/ -> e:\code\ai-weekly\app\public

jiaotashidi avatar Sep 04 '19 08:09 jiaotashidi

2019-09-04 15:13:02,308 INFO 5232 Use coreMiddleware order: ["meta","siteFile","notfound","static","bodyParser","overrideMethod","session","securities","i18n"]
2019-09-04 15:13:02,308 INFO 5232 Use appMiddleware order: []
2019-09-04 15:13:02,308 INFO 8752 [egg-static] starting static serve /public/ -> e:\code\ai-weekly\app\public
2019-09-04 15:13:02,309 INFO 10188 [egg:loader] Use middleware: static
2019-09-04 15:13:02,309 INFO 8752 [egg:loader] Use middleware: static
2019-09-04 15:13:02,309 INFO 10188 [egg:loader] Use middleware: bodyParser
2019-09-04 15:13:02,309 INFO 10188 [egg:loader] Use middleware: overrideMethod
2019-09-04 15:13:02,309 INFO 8752 [egg:loader] Use middleware: bodyParser
2019-09-04 15:13:02,309 INFO 8752 [egg:loader] Use middleware: overrideMethod
2019-09-04 15:13:02,309 INFO 5232 [egg:loader] Use middleware: meta
2019-09-04 15:13:02,309 INFO 10188 [egg:loader] Use middleware: session
2019-09-04 15:13:02,309 INFO 5232 [egg:loader] Use middleware: siteFile
2019-09-04 15:13:02,309 INFO 5232 [egg:loader] Use middleware: notfound
2019-09-04 15:13:02,309 INFO 8752 [egg:loader] Use middleware: session
2019-09-04 15:13:02,310 INFO 5232 [egg-static] starting static serve /public/ -> e:\code\ai-weekly\app\public
2019-09-04 15:13:02,310 INFO 5232 [egg:loader] Use middleware: static
2019-09-04 15:13:02,310 INFO 5232 [egg:loader] Use middleware: bodyParser
2019-09-04 15:13:02,310 INFO 5232 [egg:loader] Use middleware: overrideMethod
2019-09-04 15:13:02,311 INFO 5232 [egg:loader] Use middleware: session
2019-09-04 15:13:02,311 INFO 10188 [egg-security] use csrf middleware
2019-09-04 15:13:02,311 INFO 8752 [egg-security] use csrf middleware
2019-09-04 15:13:02,312 INFO 10188 [egg-security] use methodnoallow middleware
2019-09-04 15:13:02,312 INFO 8752 [egg-security] use methodnoallow middleware
2019-09-04 15:13:02,312 INFO 5232 [egg-security] use csrf middleware
2019-09-04 15:13:02,313 INFO 8752 [egg-security] use noopen middleware
2019-09-04 15:13:02,313 INFO 10188 [egg-security] use noopen middleware
2019-09-04 15:13:02,313 INFO 5232 [egg-security] use methodnoallow middleware
2019-09-04 15:13:02,313 INFO 10188 [egg-security] use nosniff middleware
2019-09-04 15:13:02,313 INFO 8752 [egg-security] use nosniff middleware
2019-09-04 15:13:02,314 INFO 5232 [egg-security] use noopen middleware
2019-09-04 15:13:02,314 INFO 8752 [egg-security] use xssProtection middleware
2019-09-04 15:13:02,314 INFO 10188 [egg-security] use xssProtection middleware
2019-09-04 15:13:02,315 INFO 10188 [egg-security] use xframe middleware
2019-09-04 15:13:02,315 INFO 8752 [egg-security] use xframe middleware
2019-09-04 15:13:02,315 INFO 5232 [egg-security] use nosniff middleware
2019-09-04 15:13:02,315 INFO 8752 [egg-security] use dta middleware
2019-09-04 15:13:02,315 INFO 10188 [egg-security] use dta middleware
2019-09-04 15:13:02,315 INFO 8752 [egg-security] compose 7 middlewares into one security middleware
2019-09-04 15:13:02,315 INFO 10188 [egg-security] compose 7 middlewares into one security middleware
2019-09-04 15:13:02,315 INFO 8752 [egg:loader] Use middleware: securities

jiaotashidi avatar Sep 04 '19 08:09 jiaotashidi


2019-09-04 15:13:02,315 INFO 10188 [egg:loader] Use middleware: securities
2019-09-04 15:13:02,315 INFO 8752 [egg:loader] Use middleware: i18n
2019-09-04 15:13:02,315 INFO 10188 [egg:loader] Use middleware: i18n
2019-09-04 15:13:02,315 INFO 8752 [egg:loader] Loaded middleware from ["e:\\code\\ai-weekly\\node_modules\\egg-session\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-security\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-jsonp\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-onerror\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-i18n\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-watcher\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-schedule\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-multipart\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-logrotator\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-static\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-view\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg\\app\\middleware","e:\\code\\ai-weekly\\app\\middleware"]
2019-09-04 15:13:02,315 INFO 10188 [egg:loader] Loaded middleware from ["e:\\code\\ai-weekly\\node_modules\\egg-session\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-security\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-jsonp\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-onerror\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-i18n\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-watcher\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-schedule\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-multipart\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-logrotator\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-static\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-view\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg\\app\\middleware","e:\\code\\ai-weekly\\app\\middleware"]
2019-09-04 15:13:02,316 INFO 5232 [egg-security] use xssProtection middleware
2019-09-04 15:13:02,316 INFO 8752 [egg:loader] Controller loaded: e:\code\ai-weekly\app\controller
2019-09-04 15:13:02,316 INFO 10188 [egg:loader] Controller loaded: e:\code\ai-weekly\app\controller
2019-09-04 15:13:02,316 INFO 5232 [egg-security] use xframe middleware
2019-09-04 15:13:02,317 INFO 5232 [egg-security] use dta middleware
2019-09-04 15:13:02,317 INFO 5232 [egg-security] compose 7 middlewares into one security middleware
2019-09-04 15:13:02,317 INFO 5232 [egg:loader] Use middleware: securities
2019-09-04 15:13:02,317 INFO 5232 [egg:loader] Use middleware: i18n
2019-09-04 15:13:02,317 INFO 5232 [egg:loader] Loaded middleware from ["e:\\code\\ai-weekly\\node_modules\\egg-session\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-security\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-jsonp\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-onerror\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-i18n\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-watcher\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-schedule\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-multipart\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-logrotator\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-static\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg-view\\app\\middleware","e:\\code\\ai-weekly\\node_modules\\egg\\app\\middleware","e:\\code\\ai-weekly\\app\\middleware"]
2019-09-04 15:13:02,317 INFO 5232 [egg:loader] Controller loaded: e:\code\ai-weekly\app\controller
2019-09-04 15:13:02,324 INFO 8752 [egg:core] dump config after load, 7ms
2019-09-04 15:13:02,326 INFO 10188 [egg:core] dump config after load, 10ms
2019-09-04 15:13:02,326 INFO 8752 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-core\lib\egg.js:303:10, remain ["e:\\code\\ai-weekly\\node_modules\\egg-watcher\\lib\\init.js:15:14"]
2019-09-04 15:13:02,327 INFO 5232 [egg:core] dump config after load, 9ms
2019-09-04 15:13:02,329 INFO 10188 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-core\lib\egg.js:303:10, remain ["e:\\code\\ai-weekly\\node_modules\\egg-watcher\\lib\\init.js:15:14"]
2019-09-04 15:13:02,330 INFO 5232 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-core\lib\egg.js:303:10, remain ["e:\\code\\ai-weekly\\node_modules\\egg-watcher\\lib\\init.js:15:14"]
2019-09-04 15:13:02,335 INFO 8752 [egg-watcher:application] watcher start success
2019-09-04 15:13:02,335 INFO 8752 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-watcher\lib\init.js:15:14, remain []
2019-09-04 15:13:02,335 INFO 10188 [egg-watcher:application] watcher start success
2019-09-04 15:13:02,335 INFO 10188 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-watcher\lib\init.js:15:14, remain []
2019-09-04 15:13:02,336 INFO 5232 [egg-watcher:application] watcher start success
2019-09-04 15:13:02,336 INFO 5232 [egg:core:ready_stat] end ready task e:\code\ai-weekly\node_modules\egg-watcher\lib\init.js:15:14, remain []
2019-09-04 15:13:02,346 INFO 9532 [master] app_worker#2:10188 started at 7002, remain 2 (998ms)
2019-09-04 15:13:02,348 INFO 9532 [master] app_worker#1:8752 started at 7002, remain 1 (1000ms)
2019-09-04 15:13:02,349 INFO 9532 [master] app_worker#3:5232 started at 7002, remain 0 (1001ms)
2019-09-04 15:13:02,349 INFO 9532 [master] egg started on http://127.0.0.1:7002 (1848ms)

jiaotashidi avatar Sep 04 '19 08:09 jiaotashidi

日志中没有ERROR级别的信息,都是INFO级别的信息,且信息中唯一看到有价值的一句是

Plugin development is disabled by env unmatched, require env(local) but got env is test

但是也看不出来是哪个插件报的

jiaotashidi avatar Sep 04 '19 08:09 jiaotashidi

试过重新根据官方示例创建一个新的ts项目 npm init egg --type=ts

项目初始化安装好以后,任何文件都不做修改 直接执行npm run start 也是控制台不报任何错误,然后根据浏览器访问http://127.0.0.1:7001/ 提示: Internal Server Error, real status: 500

jiaotashidi avatar Sep 04 '19 08:09 jiaotashidi

用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。

https://github.com/eggjs/egg/issues/3897#issuecomment-523822567

Jeff-Tian avatar Sep 04 '19 10:09 Jeff-Tian

用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。

#3897 (comment)

用npm run dev是可以正常启动,正常访问的

我们是想在测试环境启动,所以用的npm run start命令启动的,启动起来以后,控制台不报错,但是浏览器访问报的是500访问不了

jiaotashidi avatar Sep 04 '19 11:09 jiaotashidi

用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。

#3897 (comment)

想问一下npm run start启动以后访问报500这个问题怎么解决,因为回头要在生产环境上用,肯定是要执行npm run start命令的, 现在npm run start命令,启动以后,访问报500,本来以为自己环境配置的有问题,所以有新建了一个项目用官方的npm init egg --type=ts初始化以后,什么都不改,直接运行npm run start ,也是访问报500,和自己项目里面的表现是一致的都是500

jiaotashidi avatar Sep 04 '19 11:09 jiaotashidi

用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。

#3897 (comment)

我们另外一个项目也是用的eggjs但是没有用ts,那个项目npm run start是可以正常启动访问的, 那个项目已经上线了

jiaotashidi avatar Sep 04 '19 12:09 jiaotashidi

你先用local启动,看到错误信息,修掉,再改回去

获取 Outlook for Androidhttps://aka.ms/ghei36


From: jiaotashidi [email protected] Sent: Wednesday, September 4, 2019 8:10:06 PM To: eggjs/egg [email protected] Cc: Jeff [email protected]; Comment [email protected] Subject: Re: [eggjs/egg] egg+ts项目用npm run start启动不报错,访问报500 (#3926)

用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。

#3897 (comment)https://github.com/eggjs/egg/issues/3897#issuecomment-523822567

我们另外一个项目也是用的eggjs但是没有用ts,那个项目npm run start是可以正常启动访问的, 那个项目已经上线了

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/eggjs/egg/issues/3926?email_source=notifications&email_token=AAZWHDFXVQJD6ZLEJBFVOITQH6QR5A5CNFSM4ITOKUZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53LC5Q#issuecomment-527872374, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAZWHDGWNR3USAFNHBAJF7LQH6QR5ANCNFSM4ITOKUZQ.

Jeff-Tian avatar Sep 04 '19 12:09 Jeff-Tian

你先用local启动,看到错误信息,修掉,再改回去 获取 Outlook for Androidhttps://aka.ms/ghei36 … ________________________________ From: jiaotashidi [email protected] Sent: Wednesday, September 4, 2019 8:10:06 PM To: eggjs/egg [email protected] Cc: Jeff [email protected]; Comment [email protected] Subject: Re: [eggjs/egg] egg+ts项目用npm run start启动不报错,访问报500 (#3926) 用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。 #3897 (comment)<#3897 (comment)> 我们另外一个项目也是用的eggjs但是没有用ts,那个项目npm run start是可以正常启动访问的, 那个项目已经上线了 ― You are receiving this because you commented. Reply to this email directly, view it on GitHub<#3926?email_source=notifications&email_token=AAZWHDFXVQJD6ZLEJBFVOITQH6QR5A5CNFSM4ITOKUZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53LC5Q#issuecomment-527872374>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAZWHDGWNR3USAFNHBAJF7LQH6QR5ANCNFSM4ITOKUZQ.

set EGG_SERVER_ENV=local & npm run dev 启动不报错,可以正常访问的

jiaotashidi avatar Sep 04 '19 12:09 jiaotashidi

那可能是你 test 环境配置问题,检查下config.test.js

获取 Outlook for Androidhttps://aka.ms/ghei36


From: jiaotashidi [email protected] Sent: Wednesday, September 4, 2019 8:22:45 PM To: eggjs/egg [email protected] Cc: Jeff [email protected]; Comment [email protected] Subject: Re: [eggjs/egg] egg+ts项目用npm run start启动不报错,访问报500 (#3926)

你先用local启动,看到错误信息,修掉,再改回去 获取 Outlook for Androidhttps://aka.ms/ghei36 … ________________________________ From: jiaotashidi [email protected]mailto:[email protected] Sent: Wednesday, September 4, 2019 8:10:06 PM To: eggjs/egg [email protected]mailto:[email protected] Cc: Jeff [email protected]mailto:[email protected]; Comment [email protected]mailto:[email protected] Subject: Re: [eggjs/egg] egg+ts项目用npm run start启动不报错,访问报500 (#3926https://github.com/eggjs/egg/issues/3926) 用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。 #3897https://github.com/eggjs/egg/issues/3897 (comment)<#3897 (comment)https://github.com/eggjs/egg/issues/3897#issuecomment-523822567> 我们另外一个项目也是用的eggjs但是没有用ts,那个项目npm run start是可以正常启动访问的, 那个项目已经上线了 D You are receiving this because you commented. Reply to this email directly, view it on GitHub<#3926https://github.com/eggjs/egg/issues/3926?email_source=notifications&email_token=AAZWHDFXVQJD6ZLEJBFVOITQH6QR5A5CNFSM4ITOKUZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53LC5Q#issuecomment-527872374>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAZWHDGWNR3USAFNHBAJF7LQH6QR5ANCNFSM4ITOKUZQ.

set EGG_SERVER_ENV=local & npm run dev 启动不报错,可以正常访问的

― You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/eggjs/egg/issues/3926?email_source=notifications&email_token=AAZWHDBKGOTBRMYCHCUO47LQH6SBLA5CNFSM4ITOKUZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53MCFA#issuecomment-527876372, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAZWHDGXYHE25OQXVN3K6M3QH6SBLANCNFSM4ITOKUZQ.

Jeff-Tian avatar Sep 04 '19 12:09 Jeff-Tian

那可能是你 test 环境配置问题,检查下config.test.js 获取 Outlook for Androidhttps://aka.ms/ghei36 … ________________________________ From: jiaotashidi [email protected] Sent: Wednesday, September 4, 2019 8:22:45 PM To: eggjs/egg [email protected] Cc: Jeff [email protected]; Comment [email protected] Subject: Re: [eggjs/egg] egg+ts项目用npm run start启动不报错,访问报500 (#3926) 你先用local启动,看到错误信息,修掉,再改回去 获取 Outlook for Androidhttps://aka.ms/ghei36 … ________________________________ From: jiaotashidi [email protected]mailto:[email protected] Sent: Wednesday, September 4, 2019 8:10:06 PM To: eggjs/egg [email protected]mailto:[email protected] Cc: Jeff [email protected]mailto:[email protected]; Comment [email protected]mailto:[email protected] Subject: Re: [eggjs/egg] egg+ts项目用npm run start启动不报错,访问报500 (#3926<#3926>) 用 EGG_SERVER_ENV=local npm run dev 运行,页面上会显示具体的错误信息。npm run start 会认为在生产环境,不显示具体错误信息。 #3897<#3897> (comment)<#3897 (comment)<#3897 (comment)>> 我们另外一个项目也是用的eggjs但是没有用ts,那个项目npm run start是可以正常启动访问的, 那个项目已经上线了 D You are receiving this because you commented. Reply to this email directly, view it on GitHub<#3926<#3926>?email_source=notifications&email_token=AAZWHDFXVQJD6ZLEJBFVOITQH6QR5A5CNFSM4ITOKUZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53LC5Q#issuecomment-527872374>, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAZWHDGWNR3USAFNHBAJF7LQH6QR5ANCNFSM4ITOKUZQ. set EGG_SERVER_ENV=local & npm run dev 启动不报错,可以正常访问的 ― You are receiving this because you commented. Reply to this email directly, view it on GitHub<#3926?email_source=notifications&email_token=AAZWHDBKGOTBRMYCHCUO47LQH6SBLA5CNFSM4ITOKUZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53MCFA#issuecomment-527876372>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAZWHDGXYHE25OQXVN3K6M3QH6SBLANCNFSM4ITOK

set EGG_SERVER_ENV=test & npm run dev 也是可以跑起来的 npm run dev里面用的是egg-bin启动的,npm run start里面是用egg-scripts启动的 另外,官方的ts示例安装以后npm run start启动也是和我们项目里面启动是一样的,都是访问500

jiaotashidi avatar Sep 04 '19 12:09 jiaotashidi

那可能是你 test 环境配置问题,检查下config.test.js

想问一下为什么egg-scripts启动的时候 日志里面

2019-09-04 20:19:27,780 INFO 11596 [master] start with env: isProduction: true, EGG_SERVER_ENV: prod, NODE_ENV: production
2019-09-04 20:19:27,790 INFO 11596 [master] agent_worker#1:10312 start with clusterPort:60599
2019-09-04 20:19:28,466 INFO 10312 Plugin development is disabled by env unmatched, require env(local) but got env is prod
2019-09-04 20:19:28,487 INFO 10312 [egg:core] App root: E:\code\ai-weekly

重点看下面这一句

Plugin development is disabled by env unmatched, require env(local) but got env is prod

为什么npm run start也就是正式环境启动,里面会出现require env(local)

jiaotashidi avatar Sep 04 '19 12:09 jiaotashidi

那可能是你 test 环境配置问题,检查下config.test.js

config.test.ts配置如下

import { EggAppConfig, PowerPartial } from 'egg';

export default () => {
  const config: PowerPartial<EggAppConfig> = {};
  config.sequelize = {
    delegate: 'model', // load all models to app.portalModel and ctx.model
    baseDir: 'model',
    dialect: 'mysql',
    host: 'XXX',
    port: 3306,
    database: 'XXX',
    username: 'XXX',
    password: 'XXX',
    timezone: '+08:00',
    pool: {
      max: 3,
      min: 0,
      idle: 60000, // 闲置的连接超过多少毫秒被释放
      acquire: 60000, // 建立连接出错的时候,在抛出错误之前,池子会尝试建立连接的最大时间
      // evict: 1000 // 删除空闲连接的时间间隔
    },
  };
  return config;
};

jiaotashidi avatar Sep 04 '19 12:09 jiaotashidi