Html SyntaxError:预期表达式,get'<';1.
对于同一个问题,我尝试了所有的解决方案。但仍然显示错误。 下面的代码来自index.html,其中链接了所有依赖项。已检查了所有文件的路径 app.jsHtml SyntaxError:预期表达式,get'<';1.,html,angularjs,Html,Angularjs,对于同一个问题,我尝试了所有的解决方案。但仍然显示错误。 下面的代码来自index.html,其中链接了所有依赖项。已检查了所有文件的路径 app.js const express = require('express') const app = express() const mongoose = require('mongoose'); const bodyParser = require('body-parser'); const expressJwt = require('expre
const express = require('express')
const app = express()
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const expressJwt = require('express-jwt');
const path = require('path')
const cred = require('./server/config/cred');
// Basic usage
mongoose.connect('mongodb://localhost/orola');
console.log(cred.jwtSecret);
app.use('/secure', expressJwt({secret: cred.jwtSecret}));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/client'));
require('./server/routes/doctor')(app);
require('./server/routes/user')(app);
app.get('*', function(req, res) {
res.sendFile(path.resolve('./client/index.html'));
});
app.listen(3003, function () {
console.log('Example app listening on port 3000!')
})
浏览至
/client/app.js
。我很确定你的服务器发送了一些HTML错误,而不是实际的JS内容。你可以点击错误列表上的app.js链接。嗨,欢迎来到stackoverflow!请尝试将您的问题简化为MWE(最小工作示例)或查看。人们不太可能阅读这么多代码,但如果您能用大约10行代码重现错误,我相信我们可以帮助您。@SamiKuhmonen是的,它会打开index.html并用红色标记。您能告诉我为什么会发生这种情况,以及应该采取什么措施来纠正它吗?我假设您为任何请求设置的返回index.html的路由可能与此有关。浏览到/client/app.js
。我很确定你的服务器发送了一些HTML错误,而不是实际的JS内容。你可以点击错误列表上的app.js链接。嗨,欢迎来到stackoverflow!请尝试将您的问题简化为MWE(最小工作示例)或查看。人们不太可能阅读这么多代码,但如果您能用大约10行代码重现错误,我相信我们可以帮助您。@SamiKuhmonen是的,它会打开index.html并用红色标记。您能告诉我为什么会发生这种情况,以及应该做些什么来纠正它吗?我假设您为任何请求设置的返回index.html的路由可能与此有关。
(function () {
'use strict';
angular
.module('app',[])
.factory('loginService', Service);
function Service($http,$state,$window, $log) {
var service = {};
service.demo = function(){
console.log('hello from service');
};
return service;
}
})();
const express = require('express')
const app = express()
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const expressJwt = require('express-jwt');
const path = require('path')
const cred = require('./server/config/cred');
// Basic usage
mongoose.connect('mongodb://localhost/orola');
console.log(cred.jwtSecret);
app.use('/secure', expressJwt({secret: cred.jwtSecret}));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/client'));
require('./server/routes/doctor')(app);
require('./server/routes/user')(app);
app.get('*', function(req, res) {
res.sendFile(path.resolve('./client/index.html'));
});
app.listen(3003, function () {
console.log('Example app listening on port 3000!')
})