小编ata*_*a10的帖子

无法加载资源:服务器响应状态为404(未找到)https://websitename.herokuapp.com/js/bootstrap.js

我正在使用express.js框架在heroku上运行node.js服务器.

这是我的服务器的样子:

var express = require('express');
var app = express();

app.use(express.static(__dirname + '/static'));
var port = process.env.PORT || 8000;

app.listen(port);
Run Code Online (Sandbox Code Playgroud)

我的index.html文件包含以下javascript链接:

<script src="/js/chartview.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/bootstrap-select.js"></script>
Run Code Online (Sandbox Code Playgroud)

我的目录系统如下所示:

server.js
/static
    -index.html
    -/js
        -bootstrap.js
        -bootstrap-select.js
        -chartview.js
    -/css
        -bootstrap.css
        -bootstrap-select.css
        -styles.css
Run Code Online (Sandbox Code Playgroud)

Chrome会使用相应的css样式显示我的html页面,但控制台会说:

Failed to load resource: the server responded with a status of 404 (Not Found)   https://websitename.herokuapp.com/js/chartview.js
Failed to load resource: the server responded with a status of 404 (Not Found)   https://websitename.herokuapp.com/js/bootstrap.js
Failed to load resource: the server responded with a status …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express

3
推荐指数
1
解决办法
7万
查看次数

标签 统计

express ×1

javascript ×1

node.js ×1