![安装期间出现 EACESS 错误](https://linux22.com/image/875871/%E5%AE%89%E8%A3%85%E6%9C%9F%E9%97%B4%E5%87%BA%E7%8E%B0%20EACESS%20%E9%94%99%E8%AF%AF.png)
在程序执行期间我收到以下消息:
>> Local Npm module "grunt-cli" not found.
Grunt 已在系统中
lrwxrwxrwx 1 root root 39 Sep 13 20:29 /usr/bin/grunt -> ../lib/node_modules/grunt-cli/bin/grunt*
然后我要安装 grunt本地使用时npm install -g grunt-cli
,我收到 EACCES 错误:
$ npm install -g grunt-cli
npm ERR! Linux 3.19.0-28-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! path /usr/bin/grunt
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/usr/bin/grunt'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/usr/bin/grunt'] errno: -13, code: 'EACCES', path: '/usr/bin/grunt' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/usr/bin/grunt'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/usr/bin/grunt'] errno: -13, code: 'EACCES', path: '/usr/bin/grunt' }
npm ERR! Please include the following file with any support request:
npm ERR! /home/skydog/npm-debug.log
我该怎么做才能npm install -g grunt-cli
避免出现 EACESS 错误?
答案1
从man npm
:
global mode:
npm installs packages into the install prefix at
prefix/lib/node_modules and bins are installed in prefix/bin.
local mode:
npm installs packages into the current project directory, which
defaults to the current working directory. Packages are
installed to ./node_modules, and bins are installed to
./node_modules/.bin.
Local mode is the default. Use --global or -g on any command to operate
in global mode instead.
因此,当您使用该-g
标志时,您是npm
在全局模式下使用的。如果您想使用本地模式,请不要使用该-g
标志。