简体   繁体   English

使用CoffeeScript的Node.js,如何调试?

[英]Node.js with CoffeeScript, how to debug?

I am used to being a Front-End Developer. 我曾经是一名前端开发人员。 I am new to NodeJS. 我是NodeJS的新手。

I always use CoffeeScript to build Front-end code. 我总是使用CoffeeScript来构建前端代码。

I have a coffeescript file like the following: 我有一个如下的coffeescript文件:

http = require 'http'

http.createServer (req, res) ->
  res.writeHead 200, {'Content-Type': 'text/plain'}
  res.end 'Hello World\n'
.listen 1337

console.log 'Server running at http://127.0.0.1:1337/'

So I type command $ coffee server.coffee , It works fine, the same effect with $ node server.js 所以我输入命令$ coffee server.coffee ,它运行正常,与$ node server.js效果相同

So I decided I write my NodeJS application using CoffeScript, When I deploy it to the production environment I will compile all CoffeeScript files to Javascript files. 所以我决定使用CoffeScript编写NodeJS应用程序,当我将它部署到生产环境时,我会将所有CoffeeScript文件编译为Javascript文件。

So: 所以:

  1. I don't know how to debug CoffeeScript. 我不知道如何调试CoffeeScript。

  2. I am studying NodeJS by myself, I don't know if the above steps are correct or reasonable 我自己研究NodeJS,我不知道上述步骤是否正确或合理

This took me forever to figure out. 这让我永远想通了。

coffee --nodejs debug server.coffee

Apparently you can pass options to node by specifying the --nodejs flag. 显然,您可以通过指定--nodejs标志将选项传递给节点。 More on that in this other post 更多关于这篇文章的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM