我知道在本地如何使用coffescript了,npm install -g coffee-script,然后coffee app.coffee。 可是怎么在服务器上运行app.coffee?求指点。。。我用的appfog
6 回复
@MJerry @jiyinyiyong 我试了试成功了,app.coffee中:
http = require 'http'
http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/html'}
res.write '<h1>Node.js</h1>'
res.end '<p>Hello World</p>'
.listen 3000
console.log "HTTP server is listening at port 3000."
app.js中:
require('coffee-script');
require('./app.coffee');
package.json的"dependencies"中添上:
"coffee-script":"*"
并npm install 上传后可以了,谢谢!