> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to fix Npm install failed with "cannot run in wd"
- URL: https://til.codes/npm-install-failed-with-cannot-run-in-wd-2/
- Published: 2016-08-07T16:59:40.000Z
- Updated: 2018-02-21T06:35:10.000Z
- Author: Manu Ajith
- Tags: js, node, npm, nvm, #Import 2024-07-13 21:01

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.

**TL;DR:**

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`

References:  
1.Fixing npm permissions:[https://docs.npmjs.com/getting-started/fixing-npm-permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions?ref=til.codes)  
2.[https://docs.npmjs.com/misc/scripts#user](https://docs.npmjs.com/misc/scripts?ref=til.codes#user)