I was trying to upgrade my blogs ghost version to 0.9(which btw has some cool features) and I stumbled upon an issue when trying to upgrade the packages.
Every time I run
sudo npm install --production
on my server, I get the following error:
npm WARN cannot run in wd email@example.com node core/server/utils/npm/preinstall.js (wd=/var/www/ghost)
On digging a bit deep, I found that NPM tries to downgrade its privileges when it runs scripts. That downgrading the privileges causes this error.
So the workarounds are:
sudo npm run postinstallmanually. OR
npm install --unsafe-permOR
sudo chown -R my_name /usr/local
1.Fixing npm permissions:https://docs.npmjs.com/getting-started/fixing-npm-permissions