moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.17k stars 587 forks source link

Moleculer-runner cannot load service with compiled code from es6 #346

Closed picosix closed 6 years ago

picosix commented 6 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Expected Behavior

Current Behavior

"ServiceSchemaError: Service name can't be empty! Maybe it is not a valid Service schema."

Failure Information

The reason is at this line https://github.com/moleculerjs/moleculer/blob/master/src/service-broker.js#L533 The schema will be

{
 default: {
  name: 'service-name',
 ...
}
}

Steps to Reproduce

  1. Write some code on es6
  2. Compile it by babel-cli
  3. Load all services by moleculer-runner

Reproduce code snippet

user.service.js

export default {
 name: 'user',
 action: {
  login: async () => 'success'
 }
}

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

yarn run v1.5.1
$ NODE_ENV=production moleculer-runner -E .env.production
[2018-07-28T03:17:32.865Z] INFO  yaorut2s-macbook-pro.local-2644/BROKER: Moleculer v0.13.1 is starting...
[2018-07-28T03:17:32.867Z] INFO  yaorut2s-macbook-pro.local-2644/BROKER: Node ID: yaorut2s-macbook-pro.local-2644
[2018-07-28T03:17:32.867Z] INFO  yaorut2s-macbook-pro.local-2644/BROKER: Namespace: <not defined>
[2018-07-28T03:17:32.867Z] INFO  yaorut2s-macbook-pro.local-2644/REGISTRY: Strategy: RoundRobinStrategy
[2018-07-28T03:17:32.870Z] INFO  yaorut2s-macbook-pro.local-2644/BROKER: Serializer: JSONSerializer
[2018-07-28T03:17:32.871Z] INFO  yaorut2s-macbook-pro.local-2644/BROKER: Transporter: RedisTransporter
[2018-07-28T03:17:32.872Z] INFO  yaorut2s-macbook-pro.local-2644/BROKER: Registered 10 internal middleware(s).
ServiceSchemaError: Service name can't be empty! Maybe it is not a valid Service schema.
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c NODE_ENV=production moleculer-runner -E .env.production
Directory: /Users/picosix/Company/crawlers/facebook-graph
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/picosix/Company/crawlers/facebook-graph/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
icebob commented 6 years ago

Duplicated #328

picosix commented 6 years ago

Sorry. I was only searched by google. It's my fault

icebob commented 6 years ago

No problem.