/storage/emulated/0 is missing. Apps can't find the directory It began when I accidentally formatted the internal storage with TWRP.

Now the OS can't mount the internal storage and the /storge/emulated/0 directory is missing but when I go to settings -> storage and usb I can see that the internal storage is still there.

I can access my files through /data/media but the apps can't find the directory which is missing from /storage.

I flashed my stock kitkat ROM and it is able to detect and mount it (mounted at /storage/sdcard0) apps can access it as well

What can I do, I flashed multiple ROMs (both cyanogen and AOSP based but they can't find it!)
It may be that it is now located at /storage/sdcard0  since you flashed different ROMs with different configurations as you suggested,

alternately to run the following in emulator ;

mount -w -o remount rootfs /


then ;

ln -s /data/media/0 /sdcard


You can check with ;

ls -l -a /sdcard


Credits:


/storage/emulated/0 missing
Android 4.3 breaks Lil Debi. sdcard: '/storage/emulated/0' not a directory