typings icon indicating copy to clipboard operation
typings copied to clipboard

EACCES error when using typings as a different user

Open Tomino2112 opened this issue 8 years ago • 7 comments

This might be npm issue, or dependency issue.

Setup is:

  • Node installed as a root / global
  • Project cloned as a www-data user
  • typings installed globally sudo npm install typings -g
  • local .npmrc with settings cache = "./.npm"
  • all commands must be run as www-data

When I run sudo -u www-data typings install I get error:

Error: EACCES: permission denied, open '/home/tomas/.config/configstore/insight-typings.json'
You don't have access to this file.

    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at Object.create.all.get (/usr/lib/node_modules/typings/node_modules/configstore/index.js:34:26)
    at Object.Configstore (/usr/lib/node_modules/typings/node_modules/configstore/index.js:27:44)
    at new Insight (/usr/lib/node_modules/typings/node_modules/insight/lib/index.js:37:34)
    at Object.<anonymous> (/usr/lib/node_modules/typings/dist/utils/insight.js:6:19)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)

so even though I am running it as a www-data user, it still goes into my current user home directory for some config.

I tried to disable insights --no-insights and also tried --no-update-notifier but had no effect

Any ideas?

Tomino2112 avatar Mar 02 '16 09:03 Tomino2112

I'll be killing insights with the next release, until then, no - sorry! However, it sounds like this issue will continue with update notifier, so perhaps you could ask in configstore? I saw https://github.com/yeoman/configstore/issues/34, which is probably relevant to you.

blakeembrey avatar Mar 02 '16 17:03 blakeembrey

Insight has been removed, but we still use configstore. Is this still an issue for you?

blakeembrey avatar Mar 09 '16 22:03 blakeembrey

yes, still getting configstore issue

Tomino2112 avatar Mar 10 '16 14:03 Tomino2112

This doesn't really address your issue, but have you tried setting up node / npm to avoid sudo altogether? Eliminates some of these tricky permissions issues. John Papa wrote a great tutorial on this as a starting point: http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/ (assumes OSX, if you are on Linux you'll have to adjust accordingly).

SonofNun15 avatar Mar 29 '16 00:03 SonofNun15

@SonofNun15 of course if I setup npm without sudo then all works, but the point is, the setup has to be with sudo/has to be available for every user on the system AND the main problem is that if I use the npm command as a different user: sudo -u www-data npm install some packages are still trying to write into different user's home folder

Tomino2112 avatar Mar 29 '16 09:03 Tomino2112

That makes sense. :+1:

SonofNun15 avatar Mar 29 '16 12:03 SonofNun15

The root cause of this issue (and many like it) is https://github.com/npm/write-file-atomic/issues/11.

There is an outstanding patch which will fix this for everyone. We're all waiting for someone from npm to accept it: https://github.com/npm/write-file-atomic/pull/13

jimbojw avatar Aug 02 '16 11:08 jimbojw