/ js

How to fix Npm install failed with "cannot run in wd"

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 ghost@0.9.0 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:
1. Run `sudo npm run postinstall` manually. OR
2. Run `npm install --unsafe-perm` OR
3. Run `sudo chown -R my_name /usr/local`

1.[Fixing npm permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions)
Manu S Ajith

Manu S Ajith

Tech Entrepreneur, dating Elixir, in long-term ❤️ w/ Ruby, had multiple one night stands w/ Go. Into functional paradigms DDD/CQRS/EventSourcing architecture these days. @manusajith on the interwebs

Read More