Npm encountered an error installing bower.

  node.js, question

The following are the commands and errors:

First of all, I installed it directly according to the official documents:
[glenn@centos7 imooc]$ npm install bower -g
npm ERR! tar.unpack untar error /home/glenn/.npm/bower/1.7.9/package.tgz
npm ERR! Linux 3.10.0-327.22.2.el7.x86_64
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” “bower” “-g”
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/bower’
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/bower’]
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘mkdir’,
npm ERR! path: ‘/usr/local/lib/node_modules/bower’,
npm ERR! fstream_type: ‘Directory’,
npm ERR! fstream_path: ‘/usr/local/lib/node_modules/bower’,
npm ERR! fstream_class: ‘DirWriter’,
npm ERR! fstream_stack:
npm ERR! [ ‘/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25’,
npm ERR! ‘/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53’,
npm ERR! ‘FSReqWrap.oncomplete (fs.js:82:15)’ ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /home/glenn/Web/nodejs/imooc/npm-debug.log

Well, according to the tip, it may be a question of authority, so
[glenn@centos7 imooc]$ sudo npm install bower -g
[sudo] password for glenn:
sudo: npm: command not found
However, I can’t, I looked at the next path
[glenn@centos7 imooc]$ whereis npm
npm: /usr/local/bin/npm

Then I google it and nobody seems to have encountered this problem.

Trysudo /usr/local/bin/npm install bower -g