【发布时间】:2016-03-31 00:23:41
【问题描述】:
我在 Heroku 上部署了一个 node.js + Express + express-handlebars 应用程序。运行应用程序时,控制台显示找不到 jquery 文件 (404) 错误。这会产生级联效应,导致 Bootstrap、Datatables 等依赖库失败。
以下是我的package.json文件
{
"name": "test-node",
"version": "0.0.1",
"description": "Test node",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/username/repo.git"
},
"author": "Neeraj Jadhav",
"license": "ISC",
"bugs": {
"url": "https://github.com/username/repo/issues"
},
"homepage": "https://github.com/username/repo",
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.15.0",
"cookie-parser": "^1.4.1",
"express": "^4.13.4",
"express-handlebars": "^3.0.0",
"express-session": "^1.13.0",
"method-override": "^2.3.5",
"moment": "^2.12.0",
"mysql": "^2.10.2",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"sendgrid": "^2.0.0",
"serve-favicon": "^2.3.0",
"shortid": "^2.2.4"
},
"engines": {
"node": "0.10.28",
"npm": "1.4.9"
}
}
以下是我的node js项目文件夹结构截图。
找不到jquery-1.12.1.min.js
在我的 app.js 中,我将引用静态文件的代码行移到了其他所有人之上,但它仍然不起作用。如果我在新选项卡中打开 jquery Heroku 链接并在 js 之前添加 public,如下所示:https://admin-violet.herokuapp.com/public/js/jQuery-1.12.1.min.js,它会显示相同的错误。
知道为什么找不到 jquery 文件吗?我之前在 Heroku 上部署过 node js 项目,但从未遇到过这个问题。
感谢您的帮助。
【问题讨论】:
标签: javascript jquery node.js express heroku