Bower El Capitan安装问题

时间:2016-09-15 08:40:26

标签: node.js npm bower

有点长,但我认为包含尽可能多的信息会给我最好的机会来获得解决方案。

我在OSX 10.11.6 El Capitan。

我安装了Hombrew,并通过Homebrew安装了Node,npm和git。

我安装了xcode和命令行工具。

$ brew -v
  Homebrew 0.9.9 (git revision 09929; last commit 2016-09-15)
  Homebrew/homebrew-core (git revision 08ce; last commit 2016-09-15)

$ node -v
  v6.5.0

$ which node
  /usr/local/bin/node

$ npm -v
  3.10.3

$ which npm
  /usr/local/bin/npm

我似乎能够毫无问题地安装凉亭:

$ npm install -g bower
  /usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
  /usr/local/lib
  └── bower@1.7.9

但后来我运行bower -v来检查我的安装,我遇到了一个问题:

$ bower -v
  /usr/local/lib/node_modules/bower/lib/node_modules/configstore/index.js:54
            throw err;
            ^

   Error: EACCES: permission denied, open '/Users/username/.config/configstore/bower-github.json'
   You don't have access to this file.

      at Error (native)
      at Object.fs.openSync (fs.js:640:18)
      at Object.fs.readFileSync (fs.js:508:33)
      at Object.get (/usr/local/lib/node_modules/bower/lib/node_modules/configstore/index.js:35:26)
      at Object.Configstore (/usr/local/lib/node_modules/bower/lib/node_modules/configstore/index.js:28:44)
      at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
      at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
      at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:16:32)
      at Module._compile (module.js:556:32)
      at Object.Module._extensions..js (module.js:565:10)

所以我运行这些命令:

$ sudo chown -R $USER:$GROUP ~/.npm
$ sudo chown -R $USER:$GROUP ~/.config

然后我再次运行bower -v:

$ bower -v
  1.7.9

在我尝试安装第一个软件包之前,它似乎已经排序了:

$ bower install bootstrap --save-dev
  bower bootstrap#*           not-cached             
  https://github.com/twbs/bootstrap.git#*
  bower bootstrap#*              resolve       https://github.com/twbs/bootstrap.git#*
  bower bootstrap#*             checkout v3.3.7
  bower bootstrap#*             progress Receiving objects:  19% (78/409)
  bower bootstrap#*             progress Receiving objects:  46% (189/409), 708.00 KiB | 703.00 KiB/s
  bower bootstrap#*             progress Receiving objects:  49% (201/409), 1.73 MiB | 883.00 KiB/s
  bower bootstrap#*               EACCES EACCES: permission denied, open '/Users/username/.cache/bower/packages/478ab1d28ba78f550601bf536eea62f5-3.3.7.lock'

  Stack trace:
  Error: EACCES: permission denied, open '/Users/username/.cache/bower/packages/478ab1d28ba78f550601bf536eea62f5-3.3.7.lock'
at Error (native)

  Console trace:
  Error
      at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:81:37)
      at Logger.<anonymous> (/usr/local/lib/node_modules/bower/lib/bin/bower.js:110:26)
      at emitOne (events.js:96:13)
      at Logger.emit (events.js:188:7)
      at Logger.emit (/usr/local/lib/node_modules/bower/lib/node_modules/bower-logger/lib/Logger.js:29:39)
      at /usr/local/lib/node_modules/bower/lib/commands/index.js:48:20
      at _rejected (/usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:844:24)
      at /usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:870:30
      at Promise.when (/usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:1122:31)
      at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/bower/lib/node_modules/q/q.js:788:41)
  System info:
  Bower version: 1.7.9
  Node version: 6.5.0
  OS: Darwin 15.6.0 x64

这是我陷入困境的地方。任何帮助解决这个问题都将非常感激。

2 个答案:

答案 0 :(得分:0)

我也在使用El Capitan。我不得不删除目录以使其工作。

sudo rm -rf ~/.config/

尝试所有选项后,如chown和chmod,唯一的方法是删除目录。但我不知道这是否是最好的选择。

答案 1 :(得分:0)

sudo bower install --allow-root bootstrap