Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

npm WARN cannot run in wd / bower EACCES: permission denied, mkdir #596

Closed
bej-soan opened this issue Dec 9, 2015 · 6 comments
Closed

Comments

@bej-soan
Copy link
Contributor

bej-soan commented Dec 9, 2015

Hi,

I again came along the following cannot run in wd bug and I guess I found a workaround and thought I might share it here. Maybe it will help others or we can take a look at the source (read about it here already, but solution is not clear to me)

Bower version: 1.7.0
Node version: 4.2.2

The bug appears during npm install

bjoern:FoundationPress bjoern$ sudo npm install
Password:
npm WARN cannot run in wd [email protected] bower install && gulp build (wd=/Users/bjoern/MAMP/xxx/wp-content/themes/FoundationPress)

When I use just bower install I get

bower foundation-sites#~6.0.1   cached git://github.com/zurb/foundation-sites.git#6.0.5
bower foundation-sites#~6.0.1 validate 6.0.5 against git://github.com/zurb/foundation-sites.git#~6.0.1
bower motion-ui#~1.1.0          cached git://github.com/zurb/motion-ui.git#1.1.1
bower motion-ui#~1.1.0        validate 1.1.1 against git://github.com/zurb/motion-ui.git#~1.1.0
bower fontawesome#~4.4.0        cached git://github.com/FortAwesome/Font-Awesome.git#4.4.0
bower fontawesome#~4.4.0      validate 4.4.0 against git://github.com/FortAwesome/Font-Awesome.git#~4.4.0
bower jquery#~2.1.4             cached git://github.com/jquery/jquery.git#2.1.4
bower jquery#~2.1.4           validate 2.1.4 against git://github.com/jquery/jquery.git#~2.1.4
bower what-input#~1.1.2         cached git://github.com/ten1seven/what-input.git#1.1.3
bower what-input#~1.1.2       validate 1.1.3 against git://github.com/ten1seven/what-input.git#~1.1.2
bower                           EACCES EACCES: permission denied, mkdir '/Users/xxx/MAMP/xxx/wp-content/themes/FoundationPress/assets/components'

Stack trace:
Error: EACCES: permission denied, mkdir '/Users/xxx/MAMP/xxx/wp-content/themes/FoundationPress/assets/components'
    at Error (native)

Console trace:
Error
    at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:82:37)
    at Logger.<anonymous> (/usr/local/lib/node_modules/bower/bin/bower:110:22)
    at emitOne (events.js:77:13)
    at Logger.emit (events.js:169:7)
    at Logger.emit (/usr/local/lib/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
    at /usr/local/lib/node_modules/bower/lib/commands/index.js:68:20
    at _rejected (/usr/local/lib/node_modules/bower/node_modules/q/q.js:844:24)
    at /usr/local/lib/node_modules/bower/node_modules/q/q.js:870:30
    at Promise.when (/usr/local/lib/node_modules/bower/node_modules/q/q.js:1122:31)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/node_modules/q/q.js:788:41)
System info:
Bower version: 1.7.0
Node version: 4.2.2
OS: Darwin 15.0.0 x64

So the theres a permission problem at assets/components, so I used
sudo chown -R username /Users/username/MAMP/xxx/wp-content/themes/FoundationPress/assets/
on the asset folder.

After this bower install seemed to work, gulp build did not work.
So I used npm build and this now works.

Sorry If this is a bit confusing, but npm and stuff is try and error for me.

@colin-marshall
Copy link
Collaborator

I hear you on the trial and error with npm.

You should not run sudo when you run npm install. That would probably take care of your first issue with the permissions. Not sure about the other stuff but it might all be related. The only time you should need to run npm install with sudo is when you are installing an npm package globally, and even then it's not a good practice because your permissions are setup incorrectly.

Try deleting the node_modules and assets/components directories and run just npm install without sudo and see if that helps. Beyond that I would uninstall node/npm and reinstall it through Homebrew. I did this a few months back and ever since I have never had to use sudo with npm in any context and life seems to be easier. 👍

@joshrathke
Copy link
Contributor

Just ran into this actually. Depends on how you have your machine configured when you install everything. This should fix your problem though, essentially the issue has to do with you not having ownership of the .npm directory.

sudo chown -R $(whoami) ~/.npm

This should allow you take ownership and stop using "sudo" for your installation.

Might be worth updating the README though. This is an easy starting block for people to get into .npm and consequently pre-processing.

@colin-marshall
Copy link
Collaborator

You can run npm config get prefix to get the path to your npm installation. Then run the command @josh-rathke suggested and replace ~/.npm with the path you found in your previous step if it's different from ~/.npm.

@bej-soan you should read this first to be safe:
https://docs.npmjs.com/getting-started/fixing-npm-permissions

@bej-soan
Copy link
Contributor Author

@colin-marshall thank you for the link, I will try this. I ran into erros without sudo at npm install, can't remeber which one right now but I did not use sudo without a reason.

@Aetles
Copy link
Contributor

Aetles commented Dec 10, 2015

I've done the same thing as colin-marshall, I uninstalled node/npm and reinstalled with Homebrew so that I did not have to use sudo any more. I read some articles that helped me, like this, this and this.

@Luciaisacomputer
Copy link
Contributor

@Aetles thanks for sharing the links, I haven't really used Homebrew but now I want to check it out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants