I am currently learning angular, and now im using the official angular tutorial by google. One thing that bothers me is that I cant get the bower_components to be created inside of my working projct folder. I circumvented this problem by providing a cdn link to bootstrap and angular, but for some reason this doesnt work for the angular-router-ui link.
When I try to install bower I get this error
bower EACCES EACCES, mkdir '/home/johan/angular-phonecat/app/bower_components'
Stack trace:
Error: EACCES, mkdir '/home/johan/angular-phonecat/app/bower_components'
Console trace:
Trace
at StandardRenderer.error (/home/johan/angular-phonecat/node_modules/bower/lib/renderers/StandardRenderer.js:72:17)
at Logger.<anonymous> (/home/johan/angular-phonecat/node_modules/bower/bin/bower:111:22)
at Logger.EventEmitter.emit (events.js:95:17)
at Logger.emit (/home/johan/angular-phonecat/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
at /home/johan/angular-phonecat/node_modules/bower/lib/commands/index.js:40:20
at _rejected (/home/johan/angular-phonecat/node_modules/bower/node_modules/q/q.js:797:24)
at /home/johan/angular-phonecat/node_modules/bower/node_modules/q/q.js:823:30
at Promise.when (/home/johan/angular-phonecat/node_modules/bower/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/home/johan/angular-phonecat/node_modules/bower/node_modules/q/q.js:741:41)
at /home/johan/angular-phonecat/node_modules/bower/node_modules/q/q.js:557:44
System info:
Bower version: 1.3.7
Node version: 0.10.25
OS: Linux 3.13.0-30-generic x64
npm ERR! weird error 1
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
johan@johan-desktop:~/angular-phonecat$ ls
app bower.json LICENSE node_modules package.json README.md scripts test
johan@johan-desktop:~/angular-phonecat$ cd app
johan@johan-desktop:~/angular-phonecat/app$ ls
css img index.html js partials phones
johan@johan-desktop:~/angular-phonecat/app$ sudo npm install
[sudo] password for johan:
npm WARN cannot run in wd [email protected] bower install (wd=/home/johan/angular-phonecat)
johan@johan-desktop:~/angular-phonecat/app$
As you can see, it refused to create the bower_components folder in /app/ that I need. How to fix this? Im no ubuntu expert.
edit: The tutorial assumes that bower creates this folder inside my working folder:
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="css/app.css">
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
And as you can see in the console above, ubuntu refused to make that folder. How do I get ubuntu to create that folder?
edit2: angular-ui-router differs from angular-router, so now my workaround works perfectly. But still Im interested in the /bower_components/ folder.
When you cannot write to a directory or file, you are facing permission issues which is a result of wrong owner handling the files.
Check if your app folder is owned by you (in our case it is you, 'johan')
use the command ls -l
from the parent of your app folder and check if you own the file.
If you are not the owner of the file then use the below command to gain ownership of the file
chown -R johan:johan app
Note: This is an apt solution for this scenario as the home directory should be owned by the user. Do not change ownership of system folders or files, they will cause complex problems.