Running 'bower install' on mac - node.js

I am trying to run bower install after the installation of bower using npm is done. But the problem is when I run sudo bower install, it says bower should be run without sudo. If one runs bower install it says that permission denied cannot access file - ~/.config/configstore/bower-github.json
I tried switching to root user but no luck. What can be done to fix this?

This is how it should be solved apparently. Run the following
sudo chown -R *username* ~/
That should solve it!

Related

Create vue Permission denied

I'm trying to install vue app using this command "npm init vue#latest",
But the following error occurred with me, any help :(
Note : I tried many solutions like : chmod -R 755 .npm and sudo chown -R mostafa .npm but nothing changes
maybe you could try using the vue-cli like this:
npm install -g #vue/cli && vue create hello-world
If this wouldn't work then I'd suggest to reinstall node/npm
You should probably also make a clean installation of these tools so that you don't need to run such things as administrator
In order to install vue on your machine you must first have installed nodejs ( package manager node package manager ) to which the acronym npm refers, I leave you the linux commands under :
install :
sudo apt install nodejs
shows the installed version of nodejs :
node -v
After installing nodejs try relaunching the command to install vue
if you have already installed them try with this :
add write permissions to the study folder , and not to the mostafa folder , linux only assigns permissions to the folder in the chmod command and not subfolders, try these commands :
cd home/mostafa/Dowloads
sudo chmod ugo+w study
Are you not being blocked by SELinux directives?
Try running the same command using your least privileged user (normal user).
And please avoid using the root user for everyday tasks.
You need to have installed Nodejs, vue and create-vue.
sudo apt install nodejs
npm install vue#latest
npm install create-vue#latest
Now you can run the command to start the new project with Vue.
npm init vue#latest

getting error when using -g in npm

when I try to install any package globally, I get multiple errors. have a look at the image
the errors in the terminal
Thanks all.
When you install any global package just add sudo prefix. sudo npm install -g express
If you want to install packages globally with the "g"-parameter you must be root.
It's easy to just run sudo npm install -g express to successfully install express.
But a long time solution for the permission access, run chown -R YOUR_USERNAME /usr/lib/node_modules from your terminal so that you will not have to include sudo in your subsequent installation using -g

fail to install electron in ubuntu

I followed the command 'npm install -g electron', the command line gives me back an error 'EACCES:permission denied, mkdir /usr/local/lib/node_modules/electron/.electron'
I tried to give permission by 'chown -R root /usr/local/lib/node_modules/*', but still doen't work?
anyone seen the problem before?
solved:
at last I found you can install it directly without root or sudo
If you are using the -g flag for global, you have to either run the command as the root user or invoke the command with sudo
sudo npm install -g electron

Fix for npm global install on Ubuntu

I have a nodejs package that requires a global install. This one fails in a way that leads me to believe there might be a configuration problem in the the Ubuntu package npm. This happens every-time I setup an Ubuntu 14.04 machine.
sudo apt-get install npm
npm install -g lineman
The npm -g command will throw some access error naming the local lib and bin directories. Unlike some global installs, it is not an option to cheat and run the second command under sudo. So, the only fix I have found that will work is something like this:
sudo chgrp -R $(whoami) /usr/local/bin /usr/local/lib
sudo chmod -R g+rwx /usr/local/bin /usr/local/lib
The fix is fine for me, I'm the only user. But is this really the best way to do it? I don't want to document my fix for anyone else that might use it in an environment where this will not work or cause trouble.
Also, should I file a bug report with someone who packages npm for Ubuntu?
Instead of npm install -g lineman, you should run sudo npm install -g lineman. npm requires permission as well.
Also check this stackoverlfow link.

Run bower from root user, it's possible? How?

I have a local development server where I test a lot of things, now I'm playing with bower to manage the libraries' dependencies in my Symfony2 project. After getting NodeJS (v0.10.31) installed and bower (1.3.9), I tried to run the command sp:bower:install which belongs to Symfony2 SpBowerBundle from console as root:
Symfony > sp:bower:install
Installing bower dependencies for "TemplateBundle" into "/var/www/html/tanane/src/Tanane/TemplateBundle/Resources/config/bower/../../public/components"
bower ESUDO Cannot be run with sudo
Additional error details:
Since bower is a user command, there is no need to execute it with superuser permissions.
If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
http://www.joyent.com/blog/installing-node-and-npm
https://gist.github.com/isaacs/579814
You can however run a command with sudo using --allow-root option
I know that adding --allow-root works since I tested directly from bash but it apparently isn't allowed from the bundle command line. Now, is the only way to run bower as root to add --allow-root or does it exist another way ?
below answer is for symfony framework's bundle,
but if you come here from google using phrase "bower root" you have two options to solve that:
add --allow-root to command
set global bower config that will allow
running bower as root
Option 1: you can run bower as root by typing:
bower install --allow-root
root is allowed by setting --allow-root command parameter
Option 2: is using global setting that allows root, by creating file:
/root/.bowerrc
which have inside following configuration:
{ "allow_root": true }
how to do this in SpBowerBundle symfony bundle:
probably you haven't set sp_bower.allow_root to true in SpBowerBundle config
in bundle config, by default you have set something like this:
allow_root: false # optional
but you should have:
allow_root: true
so in app/config/config.yml add this bundle config
sp_bower:
allow_root: false # optional
bundle config reference (all settings):
https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md
If you are encountering this issue on Docker containers just add this line in your Dockerfile:
RUN echo '{ "allow_root": true }' > /root/.bowerrc
I fixed a similar problem by changing the directory permissions:
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
This might be stupid but for me bower install --allow-root did not work but bower --allow-root install did, using grunt-bower-install version 1.6.0
This was on a docker running with root user, perhaps will save someone some time :)
Faced similar issue when installing swagger-editor.
Changed the following line in package.json from
"bower-install": "bower install"
to
"bower-install": "bower install --allow-root"
This works for me (add -u parameter on docker run)
bash
docker run -it -v ${PWD}:/www -w /www -u node node ./node_modules/bower/bin/bower install
For My case it is in Pom.xml where i have added as an argument as below:
<executable>bower</executable>
<arguments>
<argument>install</argument>
<argument>--allow-root</argument>
</arguments>
If need to avoid this --allow--root parameter we can do a compile out of root user
remover / delete bower_components
and reinstall bower
bower install

Resources