Cannot run most cordova commands without using sudo - node.js

I have installed npm to setup Ionic & Cordova - and I have used sudo for this?
My question is when I run the following command without sudo I get an error:
cordova emulate ios
The error is an
EACCES, permission denied ..... /ios.json
Am I right that if I cannot use this 'basic' cordova command without running sudo my installation has been screwed up somehow?

I did the following on the terminal to allow me to run the commands without using sudo (this might help someone)
sudo chown -R $(whoami) ~/Documents/mobileapps
This meant the cordova emulate ios command now runs! finally!

Related

How would you properly install MATLAB in ubuntu that is running on WSL2?

I want to install matlab in ubuntu 20.04, but I'm running ubuntu in WSL2 and it doesn't want to work.
I keep getting the error: terminate called after throwing an instance of 'framework::window::DisplayError what(): No. Display Avaliable.
I have the linux version of matlab unzipped in a folwer and I'm trying to instal it into the user files. Things I've tried to install it that were suggested for people having the same issue on other distros:
sudo ./install
./install
bash install
install
bash ./install
sudo bash ./install
sudo su and then doing ./install
export DISPLAY=:0.0 and then sudo ./install
bash ./install -v -inputFile installer_input.txt
It gives the same error for every one that I've tried.
Let me know if anyone has any solutions. Thanks.
Posting this to help out others in the future. It actually involved a few things to get this fully working properly:
1)Had to get a X Server
2)Had to change display settings in ubuntu to get it to recognize the X server and turn off some firewall features for Windows.
3)Had to when installing matlab install using the legacy install file instead of the normal install file

Updating nodejs with homebrew dilemma: need more permission but brew doesn't work with sudo?

I am trying to update node from 10 to 12 on my mac 11.6 (20G165).
And I would like to use the homebrew way:
brew upgrade node
However, after running this, I got:
$ brew upgrade node
Error: The following directories are not writable by your user:
/usr/local/share/man/man5
/usr/local/share/man/man7
Well, then I tried the sudo way:
sudo brew upgrade node
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
What should I do to fix it now?
Can I just grant the
/usr/local/share/man/man5
/usr/local/share/man/man7
directories to my current user? Is there any risk by doing so?
My homebrew version:
Homebrew 3.2.17
Homebrew/homebrew-core (git revision 0e79905a9e5; last commit 2021-10-20)
Well I had a same problem, and solved it by commands provided which were followed by error.
sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7
And make sure that your user has write permission.
chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7

sudo throw error cannot execute binary file exec format error

I made a mistake while trying to install Rstudio in a debian with this command:
sudo gdebi rstudio-server-1.2.5033-amd64.deb
and now if I try to use sudo again, I ve got this message :
sudo apt-get update:
bash: /usr/bin/sudo : cannot execute binary file:
Exec format error
How can I reverse this error ?
Thanks
Ok so I manage to fix it, here is what I've done,
login to root with su,
remove the alter version of sudo with: apt-get remove sudo:amd64
reinstall the correct version: apt-get install sudo
exit root mode and try it gain, now it works.
thanks

sudo: npm: command not found in WSL

I'm trying to install globally some packages for my Unix environment on Windows with WSL. I use nvm to manage the different versions of Node.js.
The problem is while using the sudo command before a global npm install :
sudo npm install --global prompt-pure
I get an error: sudo: npm: command not found !
Doing a simple npm install --global pure-prompt will work, but as I'm not super user, the global installation ends up with a permission error.
How can I fix this annoying problem and keep nvm ?
Thanks by advance
When you try to run sudo npm, it tries to run the npm binary file /usr/bin/npm but your binary is located in a different place, which can be found running which npm.
Example: /home/damo/.nvm/versions/node/v8.11.1/bin/npm
The solution is to create a link in /usr/bin/ pointing to the actual binary:
sudo ln -s "$(which npm)" /usr/bin/npm
You can also add the following link so you can run sudo node
sudo ln -s "$(which node)" /usr/bin/node
For me I needed to actually cheat and run as root before installing node as root. For this I ran sudo su in a Ubuntu WSL term and then installed node.
Once I did that I could sudo su then npm run special-script.
I don't know a better way to get a script to attach to restricted ports like 443 for testing https connections but it works.
As you will find in the man file for sudo man sudo sudo will execute a command as another user. That other user has a different home directory to you and access to different commands
When i run sudo which node i get nothing, but which node returns /home/damo/.nvm/versions/node/v8.11.1/bin/node
Lets look at your actual goal. You say you are trying to install pure-prompt, i know this does not ask your explicit question but given you have zsh installed have you tried oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh) i use this on every install of linux i ever have to work with (VMs, WSL, docker). Very customizable and looks great out of the box.

chmod does not grant access to resolve the Error: spawn EACCES

I'm using node v6.4.0, npm v3.10.3, and ionic 1. I'm gettiing Error: spawn EACCES when I tried to add ios platform by: sudo ionic platform add ios or sudo cordova platform add ios.
Then I tried sudo ionic hooks add, and sudo chmod +x hooks/after_prepare/010_add_platform_class.js which was discussed in How to fix Error: spawn EACCES.
When it didn't work for me, I tried sudo chmod 777 /Users/<username>/.config/configstore/insight-cordova.json and sudo chmod 744 ~/.config/configstore/update-notifier-cordova.json. They didn't help me either. I want to know is there anything else I'm missing which can cause this error?
It is an permission issue obviously, and when you are using sudo chmod 777 -R hooks/ you are doing it wrong. Because the correct syntax is sudo [Your mode] [Your behavior flag] [Your path]. The easiest way to solve this problem is sudo as super user: sudo su on the root folder. Then You can directly run ionic platform add ios
This method worked for me.
Install dos2unix by using "sudo apt-get install dos2unix" this
command.
Then run this command "dos2unix 010_add_platform_class.js".
After that add platform again.

Resources