当我放入一个repl时,如何使我的节点程序阻塞?

时间:2015-05-19 19:53:13

标签: javascript node.js ember.js read-eval-print-loop

我只是潜入了ember插件和节点,所以这可能是一个新问题。我也来自rails / lisp背景,所以我喜欢在我的代码中删除一个repl,以便在运行时浏览。我尝试过使用节点repl,但似乎它没有阻塞,程序运行完毕。

设置

我正在尝试为插件运行一个ember生成器:

ember g addon test-addon

失败,出现此错误消息:

TypeError: Cannot read property 'name' of undefined
  at Class.module.exports.generateBowerJson (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/blueprints/addon/index.js:62:33)
  at Class.module.exports.files (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/blueprints/addon/index.js:108:10)
  at Class.Blueprint.supportsAddon (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/models/blueprint.js:783:15)
  at Class.module.exports.Task.extend.run (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/tasks/generate-from-blueprint.js:25:98)
  at Class.module.exports.Command.extend.run (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/commands/generate.js:79:17)
  at Class.<anonymous> (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/models/command.js:136:17)
  at lib$rsvp$$internal$$tryCatch (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:489:16)
  at lib$rsvp$$internal$$invokeCallback (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:501:17)
  at lib$rsvp$$internal$$publish (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:472:11)
  at lib$rsvp$asap$$flush (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1290:9)
  at process._tickDomainCallback (node.js:381:11)

我查看node_modules/ember-cli/blueprints/addon/index.js并找到我认为问题所在的位置。所以,我添加了这段代码,希望得到一个带有提示符hi>

的repl
var replServer = repl.start({
  prompt: 'hi >',
  input: process.stdin,
  output: process.stdout,
}).on('exit', function() {
  delete contents.private;
  contents.name = this.project.name();

  ^ this seems to be the problem
  rest of original code ...

但是,当我再次运行ember g addon test-addon时,它会受到提示的影响并且程序存在同样的错误:

$ember g addon test-addon
version: 0.2.5
hi >Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
  at Class.module.exports.generateBowerJson (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/blueprints/addon/index.js:58:33)
  at Class.module.exports.files (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/blueprints/addon/index.js:104:10)
  at Class.Blueprint.supportsAddon (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/models/blueprint.js:783:15)
  at Class.module.exports.Task.extend.run (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/tasks/generate-from-blueprint.js:25:98)
  at Class.module.exports.Command.extend.run (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/commands/generate.js:79:17)
  at Class.<anonymous> (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/lib/models/command.js:136:17)
  at lib$rsvp$$internal$$tryCatch (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:489:16)
  at lib$rsvp$$internal$$invokeCallback (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:501:17)
  at lib$rsvp$$internal$$publish (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:472:11)
  at lib$rsvp$asap$$flush (/Users/dixon/ember-cli/todo-mvc/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1290:9)
  at process._tickDomainCallback (node.js:381:11)

非常感谢任何帮助。谢谢!

0 个答案:

没有答案