Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute npm install hexo-cli -g promt ERR (root user) #2505

Closed
ghost opened this issue Apr 10, 2017 · 7 comments

Comments

7 participants
@ghost
Copy link

commented Apr 10, 2017

Node Version

root@debian:~# node --version
v7.8.0
root@debian:~# npm --version
4.2.0
root@debian:~#

Error Info

root@debian:~/blog# npm install hexo-cli -g
/opt/nodejs/bin/hexo -> /opt/nodejs/lib/node_modules/hexo-cli/bin/hexo

> dtrace-provider@0.8.1 install /opt/nodejs/lib/node_modules/hexo-cli/node_modules/dtrace-provider
> node scripts/install.js


> hexo-util@0.6.0 postinstall /opt/nodejs/lib/node_modules/hexo-cli/node_modules/hexo-util
> npm run build:highlight

npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/opt/nodejs/bin/node" "/opt/nodejs/bin/npm" "run" "build:highlight"
npm ERR! node v7.8.0
npm ERR! npm  v4.2.0
npm ERR! path /root/.npm/_logs
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall scandir

npm ERR! Error: EACCES: permission denied, scandir '/root/.npm/_logs'
npm ERR!  { Error: EACCES: permission denied, scandir '/root/.npm/_logs'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'scandir',
npm ERR!   path: '/root/.npm/_logs' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
glob error { Error: EACCES: permission denied, scandir '/root/.npm/_logs'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs' }

> hexo-util@0.6.0 build:highlight /opt/nodejs/lib/node_modules/hexo-cli/node_modules/hexo-util
> node scripts/build_highlight_alias.js > highlight_alias.json

npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/opt/nodejs/bin/node" "/opt/nodejs/bin/npm" "run" "build:highlight"
npm ERR! node v7.8.0
npm ERR! npm  v4.2.0

npm ERR! Callback called more than once.
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /root/.npm/_logs/2017-04-10T06_43_17_446Z-debug.log
/opt/nodejs/lib
└── (empty)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/hexo-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/opt/nodejs/bin/node" "/opt/nodejs/bin/npm" "install" "hexo-cli" "-g"
npm ERR! node v7.8.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 243

npm ERR! hexo-util@0.6.0 postinstall: `npm run build:highlight`
npm ERR! Exit status 243
npm ERR! 
npm ERR! Failed at the hexo-util@0.6.0 postinstall script 'npm run build:highlight'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the hexo-util package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build:highlight
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs hexo-util
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls hexo-util
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/.npm/_logs/2017-04-10T06_43_20_889Z-debug.log
root@debian:~/blog#
@NoahDragon

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

hexojs/hexo-util#9

Will the following solution in the above issue fix?

 $ cd /usr/bin
 $ ln -s nodejs node 
@shanyungyang

This comment has been minimized.

Copy link

commented Apr 10, 2017

Hi,

I just bumped into the same issue today with the latest docker image of nodejs. This issue can be reproduced by the following command:

# docker run -t --rm node:latest npm install -g hexo-util

It seems that the postinstall script is reading /root/.npm/_logs with a uid other than root, and here is a (dirty & insecure) workaround:

# chmod 755 /root && mkdir -m 755 -p /root/.npm/_logs
# npm install -g hexo-cli
# chmod 700 /root

CAUTION: THIS WOULD CHANGE PERMISSION OF /root! Use docker container if you want to give it a try.

@Escapingbug

This comment has been minimized.

Copy link

commented Apr 13, 2017

same problem on my manjaro linux.

@rainjm

This comment has been minimized.

Copy link

commented Apr 14, 2017

workaround:

root@xxxxxxxxxx:~# npm config set user 0
root@xxxxxxxxxx:~# npm config set unsafe-perm true
root@xxxxxxxxxx:~# npm install -g hexo
@jat001

This comment has been minimized.

Copy link

commented Apr 15, 2017

@kumashiro

This comment has been minimized.

Copy link

commented Apr 27, 2017

Safer workaround (I'm not sure about docker image):

  1. chown -R the node_modules directory to a user other than root,
  2. run npm install -g hexo-cli as that user,
  3. chown -R the node_modules directory back to root,
  4. open new beer bottle.
@levinit

This comment has been minimized.

Copy link

commented Sep 14, 2017

@Escapingbug anoter workround——ArchLinux (and other distros base on arch ,eg.manjaro) also can install 'hexo-cli' from aur:yaourt -S nodejs-hexo-cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.