Search code examples
herokumulter

error on heroku logs is due to the multer module


heroku logs
2018-06-19T03:01:34.637807+00:00 app[web.1]: 
/app/node_modules/mkdirp/index.js:90
2018-06-19T03:01:34.637822+00:00 app[web.1]: throw err0; 
2018-06-19T03:01:34.637823+00:00 app[web.1]: ^
2018-06-19T03:01:34.637824+00:00 app[web.1]:
2018-06-19T03:01:34.637826+00:00 app[web.1]: Error: EROFS: read-only file  
system, mkdir '/uploads'
2018-06-19T03:01:34.637827+00:00 app[web.1]: at Object.fs.mkdirSync 
(fs.js:885:18)
2018-06-19T03:01:34.637828+00:00 app[web.1]: at Function.sync 
(/app/node_modules/mkdirp/index.js:71:13)
2018-06-19T03:01:34.637829+00:00 app[web.1]: at new DiskStorage 
(/app/node_modules/multer/storage/disk.js:21:12)
2018-06-19T03:01:34.637831+00:00 app[web.1]: at module.exports 
(/app/node_modules/multer/storage/disk.js:65:10)
2018-06-19T03:01:34.637832+00:00 app[web.1]: at new Multer 
(/app/node_modules/multer/index.js:15:20)
2018-06-19T03:01:34.637833+00:00 app[web.1]: at multer 
(/app/node_modules/multer/index.js:95:12)
2018-06-19T03:01:34.637834+00:00 app[web.1]: at Object.<anonymous> 
(/app/server.js:18:16)
2018-06-19T03:01:34.637835+00:00 app[web.1]: at Module._compile 
(module.js:652:30)
2018-06-19T03:01:34.637836+00:00 app[web.1]: at Object.Module._extensions..js 
(module.js:663:10)
2018-06-19T03:01:34.637837+00:00 app[web.1]: at Module.load 
(module.js:565:32)
2018-06-19T03:01:34.637838+00:00 app[web.1]: at tryModuleLoad 
(module.js:505:12)
2018-06-19T03:01:34.637839+00:00 app[web.1]: at Function.Module._load 
(module.js:497:3)
2018-06-19T03:01:34.637840+00:00 app[web.1]: at Function.Module.runMain 
(module.js:693:10)
2018-06-19T03:01:34.637842+00:00 app[web.1]: at startup 
(bootstrap_node.js:188:16)
2018-06-19T03:01:34.637843+00:00 app[web.1]: at bootstrap_node.js:609:3
2018-06-19T03:01:34.715116+00:00 heroku[web.1]: State changed from starting 
to 
crashed
2018-06-19T03:01:34.697597+00:00 heroku[web.1]: Process exited with status 1
2018-06-19T05:52:50.354837+00:00 heroku[web.1]: State changed from crashed to 
starting
2018-06-19T05:52:53.881152+00:00 heroku[web.1]: Starting process with command `   node server.js

i get this error after heroku logs and my application is not running on the url which was given by heroku but heroku web local is running perfectly!

help with this issue! Thanks !


Solution

  • This probably should be /app/uploads not /uploads. The /app folder is the home directory of app and if it is relative path rather than an absolute path then it will most likely end up in the /app folder but this may depend on app configuration.

    I would just like to point out one other detail here. The filesystem app runs on a dyno is ephemeral meaning that any changes made while the dyno is running will be lost. We should not be saving uploaded files to our apps filesystem and instead, use some sort of persistent storage like Amazon S3. We have an example of how we can do this with Nodejs here. If the files we upload are only temporary then it is okay we use the dynos filesystem.

    __ credit : Tim