cant run electron on win10 ubuntu subsystem - node.js

i have a repo for an electron project ive been able to run in ubuntu subsystem before fine, im on a new pc now and having trouble. I already ran npm i, but when I run electron . i get this err:
martin#DESKTOP-URPCCBK:/mnt/c/Users/marti/Documents/projects/electron-upload-manager$ npm start
> drag-and-drop#1.0.0 start /mnt/c/Users/marti/Documents/projects/electron-upload-manager
> electron .
[5094:0907/143024.016724:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox is owned by root and has mode 4755.
so i ran
sudo chown root /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox
and
sudo chmod 4755 /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox
then ran npm start again, and get:
martin#DESKTOP-URPCCBK:/mnt/c/Users/marti/Documents/projects/electron-upload-manager$ npm start
> drag-and-drop#1.0.0 start /mnt/c/Users/marti/Documents/projects/electron-upload-manager
> electron .
[5120:0907/143308.127280:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /mnt/c/Users/marti/Documents/projects/electron-upload-manager/node_modules/electron/dist/chrome-sandbox is owned by root and has mode 4755.
I did what the error asked, but still got the error? Ive tried removing my node_modules, reinstalling with npm i, running apt-get update, installing electron globally but still am getting this err

You need to enable metadata on DrvFs. Put this in /etc/wsl.conf:
[automount]
options = "metadata"
After this, chmod/chown should work on windows files. See this Microsoft blogpost for more details.

Try this command. It is a work-around:
sudo sysctl kernel.unprivileged_userns_clone=1

ill just run it in command prompt instead, got it working fine there

Related

Command is not found when ran with sudo

I am trying to change the version of nodejs using cmd n installed globally by yarn. Neither yarn is detected by sudo nor n.
Please help me to fix this:
When running the n command to change node version, it shows permission is denied by many files to be written by n
Two approaches to avoid permission issues without requiring use of sudo when running n:
install and run Node.js from your home folder using N_PREFIX and PATH (see also n-install which automates this)
if it is your personal computer, take ownership of the folders used with default install location of /usr/local
See the project README for more: https://github.com/tj/n
(Disclaimer: I am the maintainer of n.)

Failing to install Alexa ASK-CLI "request deprecated"

I took a screenshot of the error message(s) I'm getting when trying to install the Alexa ask-cli.
typed in the command in terminal exactly like it says so in the guide
I also have a current version of node.js which is required.
First of all, “request deprecated” is not the reason which causes the failure of installation. Because ask-sdk is using it so you get the warning. you can find more Here
The problem is, the terminal you used did not have necessary permissions to access the /node_modules folder.
If you follow the instructions, are you sure that you ran the terminal with Run as Administrator option (in Windows) or sudo (in Unix)?
or you can try this:
sudo npm install -g --unsafe-perm=true --allow-root
then it should work perfectly

Running electron as root on Linux

I am making an application with electron which uses the wiring-pi library. This needs access to the GPIO on my Raspberry Pi, which requires root.
When I run electron . in the folder, the app opens fine but then says (in the terminal):
wiringPiSetup: Must be root. (Did you forget sudo?)
However when I try sudo electron ., I get an error:
sudo: electron: command not found
Does anyone know why this is happening?
Also, for the record, the same thing happens when I run npm as root:
pi#raspberrypi:~/rubiks-robot $ sudo npm
sudo: npm: command not found
Any ideas of how I can fix this issue and run Electron as root?
it looks like a problem of environment variables. The environmnet variables are set for your user but not for root.
Try to ship your variables with the "-E" switch of the sudo command:
sudo -E command
Please try to see here for other similar questions
How to keep Environment Variables when Using SUDO

Ionic, npm and cordova commands all require sudo to work

The sudo, by the looks of what I have seen in some forums, is why I am getting an error when running sudo ionic emulate ios in this post New to ionic - can’t build for ios (9) on El Capitan, and sudo ionic is required, deprecated npmconf. (I am running El Capitan btw).
Whenever I need to use an ionic, npm, or cordova command, I always have to put sudo in front of it otherwise I get a "bash command not found" error. I have tried to use this fix https://www.npmjs.com/package/npm-sudo-fix but it doesn't work. This is what happens in the log:
Dylans-MBP:Ionic Projects Dylan $ sudo npm install -g npm-sudo-fix
Password:
/usr/local/bin/npm-sudo-fix -> /usr/local/lib/node_modules/npm-sudo-fix/index.js
npm-sudo-fix#0.1.3 /usr/local/lib/node_modules/npm-sudo-fix
└── spawny#0.0.1 (cmdify#0.0.4)
Dylans-MBP:Ionic Projects Dylan$ sudo npm-sudo-fix
chown: /users/root/.npm: No such file or directory
Edit (28 August 2018):
I wrote this post and answer many years ago when I was not very familiar with the terminal. Now that I am more experienced, I can recommend the better solution. It is good practice to avoid unnecessary usages of sudo.
I believe the problem is caused by installing node JS from the installer from the node JS website. This version of node JS seems to write various files in the filesystem as root, potentially (and unnecessarily) causing global packages to require root permissions to be installed.
The ideal solution would be to completely remove node JS, that was installed from the node JS installer from the website, from your machine (see https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/). Then install node from a commandline package manager, such as homebrew.
Original Answer (2016)
Finally came up with a solution by playing with the permissions! Hopefully I didn't stuff up anything. (I am a terminal noob btw.) Anyway, here's the solution.
Run this code here in the terminal (you may or may not have to run cd .. before hand)
sudo chown -R $USER /usr/local/
This changes the permissions of every thing inside the local folder (hence the -R which means recursive). (I found this line somewhere in the ionic forums).
Now, you have to reinstall cordova and ionic
sudo npm install -g cordova
sudo npm install -g ionic
For me anyway, after I do this, I can type ionic and not get any errors. I get this in the terminal if I run cordova though.
/usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/Users/Dylan/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.
What I did to fix this was do this (after opening up a new terminal window):
sudo chown -R $USER Dylan
(Dylan is my user folder; replace it with yours. Also, you may have to do a cd .. before running that line And that fixes the permissions for that config file. Now running cordova works without errors! Woot! That error might come back though, so you have to run that line of code again.
Hope this helps somebody!

Permissions Denied in Terminal

So I am a little new to working in the terminal and trying to set up yo and a localhost environment. No matter what I do it keeps throwing a permissions denied error. I have installed node and npm already and when I run the yo install
npm install -g yo bower grunt-cli gulp i get this error message. My buddy and I have tried so many different things to fix this but we cant get anywhere. I can access and run using sudo but I need to actually have the permissions to get this working. Help please?
I am sorry if that is not detailed enough, I am new to working in the terminal and may not know entirely what I am doing. If all else fails I was going to reset my desktop to factory settings and start over with setting my users and groups.
Screenshot of errors Here
sudo chown -R `whoami` /usr/local
or
npm install npm -g
...will do the trick.
You're not the first one to experience those problems and they are (finally) actively addressed in npm#3.X.X

Resources