I encountered a problem installing then running yeoman. I've concluded that I shouldn't have installed all npm packages with sudo, but I didn't know how else to install them globally. So I got this error:

sudo yo  python-generator
                throw err;

Error: EACCES: permission denied, open '/home/me/.config/configstore/insight-yo.json'
    You don't have access to this file.
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:491:33)
    at Configstore.get (/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:34:26)
    at Configstore (/usr/local/lib/node_modules/yo/node_modules/configstore/index.js:27:44)
    at new Insight (/usr/local/lib/node_modules/yo/node_modules/insight/lib/index.js:37:34)
    at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:172:11)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)

When checking the ownership of the files in the configstore directory:

sudo ls -l /usr/local/lib/node_modules/configstore/
total 20
-rw-r--r--  1 nobody me 2409 Feb 13 13:19 index.js
drwxr-xr-x 14 root   root  4096 Apr 29 10:54 node_modules
-rw-r--r--  1 nobody me 5359 Apr 29 10:54 package.json
-rw-r--r--  1 nobody me 2178 Feb 13 13:19 readme.md

Apparently they’re owned by nobody. So I ran sudo chown -R $USER /usr/local. Now I can only install npm packages globally “without” sudo. Root can't install npm packages anymore.

I can't give ownership back to root for any of the directories it owned. What kind of implications will this have? I saw someone on another forum solve the same problem, but they created a new user, and used edited visudo to give it superuser privileges. It wasn't so clear but it seems he gave ownership of /usr/local to this new user. I didn't understand the reasoning behind giving ownership to a new user.

Is the idea to create a new user with a really strong password, turn it into something similar to root, then give this user ownership to the directories, and never log in to that new user again?

Heres the full thread: https://www.digitalocean.com/community/questions/issue-with-yo-generator-on-mean-one-click-install-image

The ambiguous part is who this $USER is. Is it matheas? If so, why does he have to rewrite the ownership of that users home directory? I'm pretty confused. But I'm concerned of the implications of now owning the whole /usr/local directory.

closed as primarily opinion-based by mikewhatever, waltinator, Eric Carvalho, Ravexina, David Foerster May 3 '17 at 10:20

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • The original error appears to relate to a file called /home/me/.config/configstore/insight-yo.json - nothing to do with /usr/local. What are the permissions and ownership of that? – steeldriver Apr 29 '17 at 12:57
  • The permissions are: -rw------- 1me me. I only changed the owner, not the group. I can see all the directories and files that should be owned by root, because they are still in the root group. I realise firefox and all kinds of applications have privileges they shouldn't have, this is pretty bad, I have to fix it. This is bad, all kinds of applications have privileges they shouldn't have. Giving ownership to a second user will prevent that. When I run yo with sudo then, it will be a superuser that owns the files so it will work. – John Slotsky Apr 29 '17 at 14:15
  • 1
    The best way to add additional information to your question is by editing it, with the edit button. It is better visible that way, and comments are mainly for secondary, temporary purposes. Comments are removed under a variety of circumstances. Anything important to your question should be in the question itself. – guntbert May 2 '17 at 20:19
  • You're going to run into heaps of issues if a user doesn't own ownership the "hidden" directories in her own home directory. If you think that a particular user-run applications shouldn't have access to a particular part of the file system you should use AppArmor rules. – David Foerster May 3 '17 at 10:18

Browse other questions tagged or ask your own question.