atom/node-keytar

How to install keytar on my Ubuntu

rliuyi opened this issue · 2 comments

Cannot install keytar on my Ubuntu

Prerequisite:
Ubuntu: 18.04.2 LTS (Bionic Beaver)
Node: v14.16.0
NPM: 6.14.11

Steps to Reproduce

  1. Run "npm install -g keytar" with root
  2. Then the following error occurs:

    keytar@7.4.0 install /usr/lib/node_modules/keytar

prebuild-install || npm run build

prebuild-install WARN install EACCES: permission denied, access '/root/.npm'
npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 65534:0 "/root/.npm"
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}

keytar@7.4.0 build /usr/lib/node_modules/keytar
node-gyp rebuild

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.16.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/keytar/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/keytar/.node-gyp'
gyp ERR! System Linux 4.15.0-45-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/keytar
gyp ERR! node -v v14.16.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keytar@7.4.0 build: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keytar@7.4.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! code ELIFECYCLE
npm ERR! errno 243
npm ERR! keytar@7.4.0 install: prebuild-install || npm run build
npm ERR! Exit status 243
npm ERR!
npm ERR! Failed at the keytar@7.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I just fix this issue via "npm install -g keytar --unsafe".
However, is there another way to fix that issue?

This is a problem with npm, not with keytar - the details in this error message are important as it mentions a suggested fix:

prebuild-install WARN install EACCES: permission denied, access '/root/.npm'
npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 65534:0 "/root/.npm"
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}