我正在 express.js 中制作一个应用程序,这是我的 app.coffee 文件:
###
Module dependencies.
###
express = require("express")
routes = require("./routes")
user = require("./routes/user")
http = require("http")
path = require("path")
app = express()
# all environments
app.set "port", process.env.PORT or 3000
app.set "views", __dirname + "/views"
app.set "view engine", "jade"
app.use express.favicon()
app.use express.logger("dev")
app.use express.bodyParser()
app.use express.methodOverride()
app.use app.router
app.use express.static(path.join(__dirname, "public"))
# development only
app.use express.errorHandler() if "development" is app.get("env")
mongoose = require 'mongoose'
mongoose.connect 'mongodb://localhost/temp', (err)->
console.log(err) if err?
console.log 'Connected'
app.get "/", routes.index
user = require './models/user'
users = require './controllers/users'
app.get '/users', users.list
app.post '/user', users.add
app.get '/user/:id', users.find
app.put '/user/:id', users.update
app.del '/user/:id', users.delete
http.createServer(app).listen app.get("port"), ->
console.log "Express server listening on port " + app.get("port")
当我尝试运行它时,我收到以下错误:
app.coffee:1:16: error: unexpected '
###
^
有任何想法吗?