我試圖使用Node.js和Express,並且我讀到了有關聲明「public」目錄來提供靜態文件的功能。我試圖把我的bootstrap css/js文件放在公共目錄中,但我一直在獲取404s。無法找到Express公共目錄
在快遞:
app.use(express.static(path.join(__dirname, '../public')));
console.log(path.join(__dirname, '../public'));
//Output: D:/app/public
在HTML:
<script src="http://localhost:6969/app/public/resources/bootstrap/js/bootstrap.js"></script>
現在,在我的文件系統:
D:\app\public //The folder
D:\app\public\resources\bootstrap\js\bootstrap.js //The file that the 404 is on
我不知道我錯過了什麼。我想我可能會誤解app.use,或者這個公共文件夾應該工作的方式。