我在Openshift nodejs中用Git bash推送我的應用程序。 我的sass1.js文件位於js文件夾中。 在我的index.html文件我把它稱爲Openshift nodejs javascript文件位置
<script src="./js/sass1.js"></script>
但我得到這個錯誤時,我期待在Firefox
「NetworkError:404未找到 - ... JS/sass1.js」
我在Openshift nodejs中用Git bash推送我的應用程序。 我的sass1.js文件位於js文件夾中。 在我的index.html文件我把它稱爲Openshift nodejs javascript文件位置
<script src="./js/sass1.js"></script>
但我得到這個錯誤時,我期待在Firefox
「NetworkError:404未找到 - ... JS/sass1.js」
你會想引用你的代碼位置與適當的環境變量。您還可以查看https://www.openshift.com/videos/getting-started-with-nodejs-on-openshift瞭解有關nodejs with openshift的更多信息。
編輯
關於第二個想法,我認爲這個線程將指向您在正確的方向https://www.openshift.com/forums/openshift/pictures-css-where-can-i-store-resources。
您需要爲nodejs express app提供靜態目錄。
app.use(express.static(__dirname+"/yourfolderwherecssisresiding")
是的,您引用的參考文獻是有幫助的。 – user1881214
對於可能遇到類似問題的人,我在下面給出了在Server.Js – user1881214
中運行的代碼self.initializeServer = function(){ self.createRoutes(); self.app = express.createServer(); forEach(函數(dir){self.app.use('/'+ dir,express.static(__ dirname +'/'))['css','img','js','plugin','lib' '+ dir)); }); //爲應用程序添加處理程序(從路線)。 (var in self.routes){ self.app.get(r,self.routes [r]); } }; – user1881214