0

I'm trying to set up Polymer project using Bower.

I am successfully installed Nodejs and Bower, but when I am tried to execute

   init bower

in the command line, I always get this error

Stack trace:
Error: EACCES, open '/kuda/bower.json'

Console trace:
Trace
at StandardRenderer.error (/usr/lib/node_modules/bower/lib/renderers/StandardRenderer.js:82:17)
at Logger.<anonymous> (/usr/lib/node_modules/bower/bin/bower:110:22)
at Logger.emit (events.js:95:17)
at Logger.emit (/usr/lib/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
at /usr/lib/node_modules/bower/lib/commands/index.js:40:20
at _rejected (/usr/lib/node_modules/bower/node_modules/q/q.js:797:24)
at /usr/lib/node_modules/bower/node_modules/q/q.js:823:30
at Promise.when (/usr/lib/node_modules/bower/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/usr/lib/node_modules/bower/node_modules/q/q.js:741:41)
at /usr/lib/node_modules/bower/node_modules/q/q.js:557:44
halfer
  • 19,824
  • 17
  • 99
  • 186
Gusti Arya
  • 1,281
  • 3
  • 15
  • 32

1 Answers1

1

You don't have permission to go to /usr/lib/node_modules/..., so this is a permission problem.

A fool would now try sudo -E bower init --allow-root but that's not really a solution (although it works). Do not do this if you do not know exactly what it does and what the risks are, that counts for all sudo commands. 'Just sudo when it doesn't work' is really not a good solution.

You probably ran sudo npm install -g bower when you installed bower, because without sudo it didn't work. When that happens, the owner of the bower program is not you, but the root user and thus you have no access to it.

Try this:

  1. Delete bower
  2. Follw this post: https://stackoverflow.com/a/21712034/4269144
  3. Do npm install -g bower, without sudo!
  4. Try init bower again
Community
  • 1
  • 1
Luc Hendriks
  • 2,473
  • 13
  • 18
  • thanks for your reply luc, i already followed the post http://stackoverflow.com/a/21712034/4269144, and now I am able install bower without sudo, but I'm still getting the same error when executing bower init. Maybe I am missing something – Gusti Arya Mar 16 '15 at 16:00
  • Does the `npm` directory exist? Otherwise try `mkdir ~/npm`. Also, you could try to do `source ~/.bashrc`. – Luc Hendriks Mar 16 '15 at 16:02