Final permissions on OS X Bower and NPM - macos

hope you having a good day.
I am a Web Frontend designer and i'm tired about MAC OSX El Capitan and his sick permissions systems on files and folders, the next is happening:
Every time that i tried to get any Bower package, NPM, or whatever console package i get this problem:
Example: 'Bower install angular-translate'
Console response:
'Error: EACCES: permission denied, open '/Users/carl/.config/configstore/bower-github.json'
You don't have access to this file.'
This is not just for this package in specific, it happend with everything that i tried to download/install in every place in my laptop.
I am the administrator on this machine, i been google that like 5 or 10 times always getting same results and always going to the same way (solutions like 'chmod-R 777* on the folder/file').
My question is the next:
There is some 'permanent' way to get all my files and folders 'global' administrator permissions no matter what? i mean, i know that is not secure, pero it is ok, i am the only one who use this laptop.
Thank you so much for your help.
Best Regards.

In order to solve the issue. I ran the command 'sudo chown -R $USER ~/' from the terminal. While inside the same terminal window, I then ran 'bower install' which solved my issue! Afterwards, I was able to install other packages(Ex. bower install bootstrap --save.

Related

Vue CLI Fails to install for Mac Mojave

I get the following error when setting up a new Vue project:
npm install -g #vue/cli
Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
I got around this error by changing permissions for two directories:
Set permissions to Everyone - Read / Write for
/usr/local/lib/node_modules
/usr/local/bin
Open Finder.
Press Command +Shift+G. A dialog box opens.
Enter the path and click Go
Right-click the directory and select Get Info
Click the lock icon to allow changes and enter your credentials
In the Sharing & Permissions section change everyone to Read & Write
Click the cog icon and select Apply to enclosed items from the drop down
Confirm the prompt
Reference Article:
https://forum.vuejs.org/t/vue-cli-installation-fails-on-macos-mojave-10-14/45712/5
As far as I know, its not just a Vue Cli issue but can happen for any node module.
Often this happens if you installed NPM as an administrator or using Sudo. You can usually get around it by doing something like sudo npm install xxx-package-xxx But that really just compounds the problem down the road when lots of things need elevated privileges.
In my case uninstalling and re-installing Node + NPM with a new package (not the ones included with MacOS) kind of helped but I eventually ended up nuking my OS and installing everything fresh.

Flutter commands is not workimg

when I run flutter command as a root user it did not run but it show something like an error
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
📎
Doctor summary (to see all details, run flutter doctor -v):
Dart_NewStringFromUTF8 expects argument 'str' to be valid UTF-8.
I do not understand what I am doing wrong .Kindly help me.
I am trying to run flutter in Kali Linux with android studio installed.
Did I need to run flutter as a non-root user, if yes then I need to install everything for another user . is there any way to do this?
Since you have installed the android studio in your root account.
there is no other option for you.
you have to give a non-root user the permission to use it.
you cant log in the shell alone also.
I recommend you to install only flutter there and use in some text editor an shell commands that's better than as.
kali has some different rules than normal Linux repos.
Run flutter doctor
and do as it suggest

Why can I import certain modules in Python only with administrator rights?

I'm struggling with some strange issues in Python 2.7. I wrote a very long tool where I import different modules, which I had to install first using pip. The tool is to be shared within the company, where different users have different rights on their specific machines.
The problem occurred when another user logged into my machine (I'm having administrator rights there) and tried to use the tool. He was unable to run it, because specific modules could not be imported because of his status as a "non-admin".
The error message is simply "No module named XY".
When we looked into the file system, we found that we were not able to look into the folder where the module had been installed, simply because the access was denied by the system.
We also got this error message when trying to run pip from the cmd; it prints "Access denied" and won't do anything.
How is it possible, that some modules can be accessed by anyone, while others can't? And how can I get around this problem?
Specifically, I'm talking about sqlalchemy and pyodbc.
Thanks a lot in advance.
EDIT 1: Oh, and we're talking about Windows here, not Linux...
EDIT 2: Due to company policy it is not possible to set administrator permissions to all users. I tried, as suggested, but it didn't work and I learned that it's not possible within the company.
Got it...
Following the advice of Nabeel Ahmed, I first uninstalled the packages which caused the issues from my admin account. Then I changed the script to
pip install --user {module_name}
and voila... it works for all users now.
Thanks a lot for you help, guys!
You should either use virtualenv as stated before or set the proper permissions to the site-packages folder. I should be in C:\Python27\Lib.
One simply solution is set permissions for site-package directory (where the packages gt installed) as per usable by all i.e. read and execute permission for all on the directory:
sudo chmod -Rv ugo+rX /usr/lib/python2.7/site-packages/
Also for the lib64 packages - the path to site-packages may vary for various Linux distros.
Edit 1: For windows look into this 'File and Folder Permissions' for setting Read & Execute permissions for all, for a file or folder (i.e. site-packges)
The path 'd be - C:\Python27\Lib\site-packages
Edit 2: in apropos of:
EDIT 2: Due to company policy it is not possible to set administrator
permissions to all users. I tried, as suggested, but it didn't work
and I learned that it's not possible within the company.
if so, simply install sqlalchemy (or any other package) for specific user using pip:
pip install --user {module_name}
Source: Per user site-packages directory.

Meteor requires sudo to run

Previously I was able to start Meteor 0.6.6.3 by simply running mrt.
Recently, Meteor 0.7.0.1 wont run properly unless I run it as root with sudo mrt. Environmental variables like MONGO_URL requires root to set it.
Any ideas what happened? I'm using Mountain Lion on Mac OSX.
You might have run it with sudo once before. When you run it with sudo just once and a file is written the files become root files root user file so it needs more permissions to run and wont run
ordinarily.
You might have run sudo mrt once it must have updated files for a package but they're now owned by root instead of your normal user.
I'm sure theres a terminal command to get it back but using Disk Utility and running 'Repair Disk Permissions' can also fix it (i think).

Why does npm need sudo for EVERYTHING?

I don't know how I've managed it but npm seems to need sudo for absolutely every command, even npm help does not work without sudo. If I use a command without sudo, I do not see am EACCESS error, but instead my terminal session hangs and then just closes that tab (I use iTerm on Mac).
I have tried changing the ownership of my local .npm folder, outlined here and also done the same on my /usr/local/bin folder where node is installed but none of these allow me to just run npm without sudo, even when installing local packages...! It seems to me that something has screwed along the way, can anyone help?
Many thanks
I encountered the same error after a fresh install of 0.12.4 today; this solved the problem for me:
sudo chown -R $(whoami):admin /usr/local/lib/node_modules
In my particular case, I noticed that this folder was owned by '{some-large-integer-account}:wheel'...YMMV
If that doesn't solve it, take a look at the ownership of the folders that are being blocked as mentioned in the EACCESS error trace. If you're not sure what the ownership should be, you can usually infer it from the sibling dirs' ownership.
I had this as well on my machine. What I did to fix it (there are probably much less extreme ways) was to completely remove npm, and then did a fresh installation node.js (with which npm is included) from http://nodejs.org/ making sure I didn't install as root. That then allowed me to use npm without root (except for global installs).
Take ember project for example, I give all related project directory root:
neil#neil-System-Product-Name:~/Projects/ember-quickstart$ sudo chown -R $(whoami) /home/neil/Projects/ember-quickstart/
neil#neil-System-Product-Name:~/Projects/ember-quickstart$ ember s
Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:7020
Build successful (10679ms) – Serving on http://localhost:4200/
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
Babel (18) | 7561ms (420 ms)
Concat (8) | 1872ms (234 ms)
Rollup (1) | 629ms
Use the below option.
Open the terminal and cd to your Home directory and run the below command.
mkdir "${HOME}/.npm-packages"
Then this command after that.
npm config set prefix "${HOME}/.npm-packages"
Next, open your .zshrc file using the open -t .zshrc command and add the following to it.
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$PATH:$NPM_PACKAGES/bin"
# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

Resources