ENOENT error when deploy to heroku
See original GitHub issuethe error:
2018-05-12T05:47:21.500393+00:00 app[web.1]: HTTP request POST /api/postImage/ {}
2018-05-12T05:47:21.501779+00:00 app[web.1]: HTTP request undefined POST /api/postImage/ {}
2018-05-12T05:47:21.591203+00:00 app[web.1]: { Error: ENOENT: no such file or directory, open '/app/static/uploads/76cc729da26dc8da18cda7924fc5eaf31526104041562.png'
2018-05-12T05:47:21.591209+00:00 app[web.1]: code: 'ENOENT',
2018-05-12T05:47:21.591213+00:00 app[web.1]: syscall: 'open',
2018-05-12T05:47:21.591216+00:00 app[web.1]: path: '/app/static/uploads/76cc729da26dc8da18cda7924fc5eaf31526104041562.png',
2018-05-12T05:47:21.591217+00:00 app[web.1]: storageErrors: [] }
2018-05-12T05:47:21.591207+00:00 app[web.1]: errno: -2,
multer setup:
var multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, path.join(__dirname, '/static/uploads/'))
// cb(null, "localhost:" + process.env.PORT + '/static/uploads/')
},
filename: function (req, file, cb) {
crypto.pseudoRandomBytes(16, function (err, raw) {
cb(null, raw.toString('hex') + Date.now() + '.' + mime.extension(file.mimetype));
});
}
});
var upload = multer({storage: storage});
and port is set to:
var PORT = process.env.PORT || 3000;
project structure:
what did i mess up?
Thanks in advance!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:18 (4 by maintainers)
Top Results From Across the Web
Troubleshooting Node.js Deploys
Your Node.js deploy failed - now what? Start with these simple steps to troubleshoot a build issue. Check the buildpack.
Read more >ENOENT error in Heroku deployment when typing in or ...
ENOENT error in Heroku deployment when typing in or redirecting to any route other than index. I have a monorepo project with this...
Read more >Heroku Error: ENOENT: no such file or directory, stat '/app ...
So, I went into my local CLI and ran heroku run bash , viewed the current files and directories, and found that /app/client/build/...
Read more >[Solved]-ENOENT error using nodejs on heroku
Related Query · CORS error in nodejs app deployed on heroku using with angular 9 · spawn ENOENT error with NodeJS while using...
Read more >MERN Deploy Heroku Fail
Issues attempting to deploy to heroku. ... --prefix client && npm run build --prefix client npm ERR! code ENOENT npm ERR! syscall open...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was having the same issue after deploying my Mean Stack app to heroku. I was pushing the code with empty uploads folder. After adding a temporary file in uploads folder , Issue is gone.
It seems like the
/app/static/uploads/
directory doesn’t exist. Might it be that the Heroku client doesn’t upload empty folders? Or that it’s ignored in some.*ignore
file?I would suggest creating the directory when the process starts for the first time: