[英]Express JS: Can I still have <scripts> in my index.html
When converting an index.html page to be served up by Express, instead of Webstorm, I noticed that all my scripts suddenly reported 404 - Not Found
, where previously they were found just fine. 当转换要由Express而不是Webstorm提供服务的index.html页面时,我注意到我的所有脚本突然报告
404 - Not Found
,以前发现它们很好。
Should I not be serving up a page from Express that has a bunch of tags? 我是否应该从Express中投放带有大量标签的页面? If it is OK to do so, how come they are all
404-Not found
now, where previously they were found just fine? 如果可以的话,为什么现在都
404-Not found
以前找不到它们)?
EDIT: Directory structure: project --- src --- js main.js --- css index.html app.js <-- all the express code
编辑:目录结构:
project --- src --- js main.js --- css index.html app.js <-- all the express code
Express code includes these lines: Express代码包括以下几行:
app.use(express.static(__dirname + '/js'));
app.use(express.static(__dirname + '/css'));
Make sure Express is set up to serve your static assets. 确保已设置Express以服务您的静态资产。 By default it will serve these from
/public
默认情况下,它将从
/public
app.use(express.static(path.join(__dirname, 'public')));
You can add your scripts there (recommended!) or add additional express.static
statements pointing to your specific scripts folder. 您可以在此处添加脚本(推荐!),也可以添加指向特定脚本文件夹的其他
express.static
语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.