node.js - Heroku Node App Resources Not Loading -
i have express node app runs fine locally, when deploy heroku files under /public
, /bower_components
not found.
this post seemed have similar problem, solution did not work me.
here relevant part of app.js:
app.use(express.static(path.join(__dirname, 'public'))); app.use('/bower_components', express.static(__dirname + '/bower_components'));
here package.json file:
{ "name": "myapp", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www", "postinstall": "bower install" }, "dependencies": { "express": "~4.9.0", "body-parser": "~1.8.1", "cookie-parser": "~1.3.3", "consolidate": "~0.10.0", "morgan": "~1.3.0", "serve-favicon": "~2.1.3", "debug": "~2.0.0", "bower": "^1.3.12", "dustjs-helpers": "~1.4.0", "dustjs-linkedin": "~2.5.0", "node-compass": "0.2.3" }, "engines": { "npm": "2.7.1" } }
in browser console can verify files present
this leads me believe there issue heroku reading __dirname correctly.
this issue solved post. node.js express app crashes on heroku, works locally
i had move following lines above other app configuration lines in app.js
app.use(express.static(path.join(__dirname, 'public'))); app.use('/bower_components', express.static(__dirname + '/bower_components'));
Comments
Post a Comment