Issues with Bower on Ubuntu - node.js

Currently having issues with using Bower on Ubuntu
I attempt to use bower install, bower init and I am advised not to use sudo, but when I do I get the following error
bower EACCES EACCES: permission denied, open '/var/www/xxxxxx/html/wp-content/themes/xxxxxxxx/bower.json'
Stack trace:
Error: EACCES: permission denied, open '/var/www/xxxxxx/html/wp-content/themes/xxxxxxxx/bower.json'
at Error (native)
Console trace:
Error
at StandardRenderer.error (/usr/local/lib/node_modules/bower/lib/renderers/StandardRenderer.js:81:37)
at Logger. (/usr/local/lib/node_modules/bower/lib/bin/bower.js:110:26)
at emitOne (events.js:77:13)
at Logger.emit (events.js:169: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: 4.2.6
OS: Linux 4.4.0-36-generic x64
The only thing that works is the following sudo bower install --allow-roots
Is there any way around this ?

You have to have permission to the directory you are trying to install files in. So you have to use bower as a user who has access to this folder (eg www-data on Ubuntu: sudo -u www-data bower install)

Related

How to fix permission being denied when installing Angular Client on MacOS?

I am a new coder trying to get started with Angular and Node following a tutorial on Udemy. I have successfully (I think) installed Node.js and I'm running version 16.15.1 but when I try to install the angular client it fails every time (screenshot attached). Please could someone point out where I am going wrong?
FYI my name is Manraj and I am the only user on my mac (hence I am an admin) so that is why it appears in the code as Manrajs MBP as that is the name of my laptop.
Last login: Tue Jun 21 15:35:36 on ttys000
[manrajsandhu#Manrajs-MBP~ % node
v16.15.1
(manrajsandhu#Manrajs-MBP ~ % pm itstall -g #angular/cli
pm WARN config global
--global
--local
are deprecated. Use
npm
ERRII
code EACCES
npm
ERR syscall rename
npm
RR
path /usr/local/lib/node_modules/#angular/cli
npm
ERR
dest /usr/local/lib/node modules/#angular/.cli-G39XYeT9
AR
errno -13
-location=global
instead.
npm
nom
PRR
non
SRR
npm
npm
-RR
•RR
npm
RR
npm
nom
ERR
ERD
nom
RR
Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/#angular/cli'
->
[Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/#angular/cli'
"/usr/local/lib
errno: -13,
"/usr/local/1
code: 'EACCES
syscall: 'rename'
path: '/usr/local/lib/node_modules/#angular/cli
dest:'/usr/local/lib/node_modules/Cangular/.cli-639XYeT9'
npm
ERR
npm
ERRI
npm
ERRI
npm
ERR
The operation was rejected by your operating system
It is likely you do not have the permissions to access this file as the current user
npm
RR
npm
ERR
npm
If you believe this might be a permissions issue, please double-check the
permissions of the file and its containing directories,
the command again as root/Administrator
or try running
nom
ERRII
mpm
EDD
A complete log of this run can be found in:
/Users/manrajsandhu/.npm/_logs/2022-06-21T14_36_16_571Z-debug-0.10g
manrajsandhu#Manrajs-MBP
%
You need root privileges. Just use sudo.
sudo npm install -g #angular/cli

Permission denied when downgrading version node in Ubuntu

Im trying to downgrade node version with this command: npm install -g n but I have this error: [Error: EACCES: permission denied, unlink '/usr/local/bin/n']
Then, I have to use this command to downgrade: n 6.10.3
How can I fix the permission denied error?
Use sudo npm install -g n to run the command as a super user.

mkdir permission error while importing oracledb#3.0.0 with Node#10.9.0

While I am trying to import oracledb#3.0.0 using Node 10.9.0, I am getting below error,
oracledb Beginning installation
oracledb Verifying installation
oracledb Continuing installation
oracledb ERR! NJS-054: Binary build/Release/oracledb.node was not installed.
oracledb ERR! Failed to install binary package oracledb-v3.0.0-node-abi64-linux-x64.gz
oracledb ERR! EACCES: permission denied, mkdir 'build'
oracledb ERR! For help see https://oracle.github.io/node-oracledb/INSTALL.html#troubleshooting
Since above code seems to be permission issue, I also tried sudo npm i mypck#3.2.0 but then it gives below error
sudo: npm: command not found
Question:
How can I give permission to create directory or execute command npm with sudo rights, any help would be deeply appreciated.
Utilize --unsafe-perm=true and --allow-root flags with npm install.
npm install -g oracledb#3.0.0 --unsafe-perm=true --allow-root
You can read more o this here : https://docs.npmjs.com/getting-started/fixing-npm-permissions

Bower El Capitan install issues

A bit of a long one but I figure including as much info as I can will give me the best chance of getting a solution.
I am on OSX 10.11.6 El Capitan.
I have Hombrew installed and Node, npm and git via Homebrew.
I have xcode and command line tools installed.
$ 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
I seem to be able to install bower without issue:
$ npm install -g bower
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
/usr/local/lib
└── bower#1.7.9
But then I run bower -v to check my install and I run in to a problem:
$ 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)
So I run these commands:
$ sudo chown -R $USER:$GROUP ~/.npm
$ sudo chown -R $USER:$GROUP ~/.config
And then I run bower -v again:
$ bower -v
1.7.9
It looks to be sorted until I try and install my first package:
$ 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
This is where I'm getting stuck. Any help solving this would be much appreciated.
I'm using El Capitan too. I had to delete the directory to manage to make it work.
sudo rm -rf ~/.config/
After trying all of the options, like chown and chmod, the only way was removing the directory. But I don't know if this is the best option.
sudo bower install --allow-root bootstrap

Koding - Yeoman - AngularFullStack Cannot Create Scaffolding

Hello i am using Koding Cloud Based Ubuntu Development environment.
I've managed to is install all prerequisites required for Yeoman Angular FullStack.
Installed Successfully below items
sudo npm install -g yo grunt-cli bower karma
sudo npm install -g generator-angular-fullstack
After installing above.
i've created abltd directory (Folder structure shown below)
and ran following command
yo angular-fullstack abltd
it ran all to the end and throwing following error.
1070 error Error: EACCES, mkdir '/home/abitandco/tmp/npm-1293-IkfHqNho'
1070 error { [Error: EACCES, mkdir '/home/abitandco/tmp/npm-1293-IkfHqNho']
1070 error errno: 3,
1070 error code: 'EACCES',
1070 error path: '/home/abitandco/tmp/npm-1293-IkfHqNho',
1070 error parent: 'abltd' }
1071 error Please try running this command again as root/Administrator.
1072 error System Linux 3.13.0-29-generic
1073 error command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
1074 error cwd /home/abitandco/abltd
1075 error node -v v0.10.26
1076 error npm -v 1.4.3
1077 error path /home/abitandco/tmp/npm-1293-IkfHqNho
1078 error code EACCES
1079 error errno 3
1080 error stack Error: EACCES, mkdir '/home/abitandco/tmp/npm-1293-IkfHqNho'
1081 verbose exit [ 3, true ]
i tried running as sudo yo angular-fullstack abltd but no difference.
i am adding complete log and image as well to help understand problem better.
Can anyone point me in right direction please.
I have complete npm debug log if any one wants to see it.
its likely that your ~/.npm or ~/tmp directories are owned by the root user. try again but ensure that those directories are owned by your username.
Give yourself permission using the following command
sudo chown -R youruser /home/youruser

Resources