当我在本地运行我的应用程序时,一切都按预期工作,但当我将它部署到cloudno.de时,它看起来像this。
我收到错误Uncaught SyntaxError: Unexpected token <
,因为greeting.js
的内容是
<!doctype html>
<html lang="en">
.......
显然不是我的javascript文件,而是我index.html的内容
我的项目勉强启动,使用Backbone Boilerplate,可以查看整个代码here。
有谁知道这可能是什么原因?
我的server.js:
// Require libraries
var fs = require("fs");
var express = require("express");
var site = express.createServer();
// Determine which dist directory to use
var dir = process.argv.length > 2 && "./dist/" + process.argv[2];
// Use custom JS folder based off debug or release
dir && site.use("/assets/js", express.static(dir + "/js"));
dir && site.use("/assets/css", express.static(dir + "/css"));
// Serve static files
site.use("/app", express.static("./app"));
site.use("/assets", express.static("./assets"));
site.use("/dist", express.static("./dist"));
// Ensure all routes go home, client side app..
site.get("*", function(req, res) {
fs.createReadStream("./index.html").pipe(res);
});
site.listen(8000);
console.log("Server listening on http://localhost:8000");
答案 0 :(得分:2)
您是否复制并粘贴了此代码?你有var dir = process.argv
...行吗?
错误可能是由于没有参数初始化cloudno.de。您的应用正在process.arv