Problem with sharp module on Debian - fixed

I have been having trouble with the update of Ghost for the last few upgrades due to an error in the sharp npm module.
…"",“stack”:"InternalServerError: Sharp wasn’t installed\n at new InternalServerError …

The symptom was the site crashed when trying to add a photo! Tracked this down by running ghost using the ‘ghost run’ command and looking at the output.
Initial workaround was to remove the sharp modules by navigating to the folder with the latest version and running ‘npm uninstall sharp’ and then restarting ghost.
Ghost error handing allowed the absence of the sharp module but this seemed a bit unsatisfactory.
However reading the sharp npm site here …

says that …
‘ There are changes in the C++11 ABI when using v5.1+ of the g++ compiler. If you have installed libvips-dev via package manager on an OS such as Debian testing/unstable, you can pass the required value of the _GLIBCXX_USE_CXX11_ABI macro using the --sharp-cxx11 flag.’

So I navigated back the the theme directory, after uninstalling sharp, and ran
‘npm install --sharp-cxx11=1’ to see if this worked for me!
It does! Hurray!
sharp installed successfully and the add photo functionality now works fine in ghost with no errors.

I am sure if you are using the official stack there will be no such problems but this fixed my install.

A further update. While I thought I had fixed the problem it turns out sharp was still not being used as intended with images being resized. An error was being thrown ‘failed to map segment from shared object’ by ghost and was in the log if ghost was run in debug mode (ghost run).

Further investigation led to this link …

The NAS drive I have ghost installed on was mounted with the noexec option which prevents the execution of binary files. I found the link above and after some reading understood that if I remounted the NAS drive with exec and not noexec I might fix the problem.

This was correct remounting the drive with the exec option prevented the error and images are saved corrected in subfolders in the content/images directory in ghost. So my guidance of uninstalling and reinstalling sharp given above was incorrect for me and while it prevented Ghost from failing it did not enable the correct operation of sharp.

I hope this helps someone.