Electron and NodeJS is unable to write logs to a file - node.js

I am running a nodejs app inside electron. The nodejs app writes logs to a log file that sits in a same installed path of the app.
I then use electron builder to build an installer. On a windows machine when I install the application under C:\Users\username, the nodejs app writes logs to the log file without any issue. But the problem arises when the app is installed under C:\Program Files\MyApp, the app shows the following error:
Error: EPERM: operation not permitted, open 'C:\Program
Files\MyApp\resources\app.asar.unpacked\server\logs\output.log'
However if I run the app as an administrator then it works perfectly. This clearly is a permission issue. How do I make my app write to the log in the above mentioned path without any admin privileges?
Thanks in advance.

Windows does not provide permission to write to Program Files directory unless you have administrator privileges. Either you have to force user to run you program as administrator or write logs to a folder like C:\Users\<username>\AppData\Local\<yourappname> as most applications does

Its better to store the logs somewhere in
path.join(app.getPath('userData'),'logs');
https://github.com/electron/electron/blob/master/docs/api/app.md#appgetpathname

Related

NX for Angular preventing certain operations from running?

With NX 14.8.1 for Angular 14.2.4, the file 'node_modules/.cache/nx/d/daemon.log' is preventing operations such as yarn install from running properly. When running yarn install, the following error is displayed in the console.
Error: EPERM: operation not permitted, unlink 'C:\Users\user\Programming\project\project2\ClientApp\node_modules.cache\nx\d\daemon.log'
Note: user, project, and project 2 are replacements for the real directories. user has a space in it, which has caused problems for nx before.
The file daemon.log does not allow me to delete it via File Explorer or PowerShell rm. File Explorer prompts for Admin but says that access is denied when I do, and PowerShell fails to run with an access is denied error. I am also unable to delete it via rm in Windows Subsystem for Linux Ubuntu, with a similar error to PowerShell rm. In File Explorer, I am unable to edit the permissions of the file to allow it to be deleted.
It seems funny but using any file unlocker would help.
I just use IOrbit unlocker to unlock and delete the deamon.log and nx build just started working.

nodeJs installation error on windows 10 - error 2203

I have downloaded version 12 of nodeJs, but unable to install on Windows.
Error - "The installer has encountered an unexpected error installing this package.
This may indicate a problem with this package.The error code is 2203".
I have tried some solutions like giving permissions to Temp folder in C:/Windows folder, running as Admin although the usual user has full permissions.
Error code 2203 basically pops up when the user does not have
sufficient permissions to install the program to the folder that
contains the installation point or the temp folder. Make sure that you
are logged in as an Administrator to install the programs on the
computer
Run installation with elevated permission ( try to run a program with admin privilege). This should solve the issue.

How to debug your application with root permissions on VSCODE?

I'm trying to debug dotnet core web app, however it's not possible to do it without having root permissions.
An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.Private.CoreLib.dll: 'Permission denied'
The naive approach would be launching VSCode with root permissions, which is generally not a recommended (and I would like to avoid it).
Is there any way to configure launch.json to execute the debugger with root permissions?
I've tried already creating a pre-launch task executing sudo or sudo su commands.
I tried running the application and trying to attach to the process (also got declined because of insufficient permissions)
For C#:
Locate vsdbg-ui (in my case: ~/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.debugger)
Rename "vsdbg-ui" to "vsdbg-ui2"
Create a new file in the same folder called "vsdbg-ui" with following content:
pkexec [yourhomefolder]/.vscode/extensions/ms-dotnettools.csharp-1.23.17/.debugger/vsdbg-ui2
Make the new file "vsdbg-ui" executable
Launch the debugging session in VSCode. You will get a prompt to enter your sudo password. You are debugging with sudo now.

Kapow ManagementConsole could not start

An error message pops out when I try to connect to the management console. The version is Kapow 10.1.0 master nightly 2370 x64.
The Error message is:
Unable to register to the default cluster: ManagementConsole failed to start: Spring subsystem failed to load.. Retrying
I had to delete the folder on Kapow Appdata User Profile folder, for example:
C:\users\<user>\appdata\local\Kapow
And then restart the RoboServer/Management Console.
This will create a new configuration and from there you can continue the installation (bring up the management console, enter the license, etc)
Please Delete Appdata and open localhost:50080 Management console and delete and then add Cluster settings again.
Now restart the Design studio and open it up again. Make sure you are using same objectdb.
You only need to rename the folder:
C:\Users\<user>\AppData\Local\Kapow\10.ur.version\Data
Then rerun the Management console as Administrator.
If you are still facing the same issue, please uninstall Kapow and install it again (also make sure you renamed the Data folder).

Setup.exe is rolling back (Built for Asp.net Application In Install Shield12)

I build Setup.exe file in Install Shield 12 for Web Project of .Net Framework.
When i m going to run this setup.exe file , i got rolling back error while execute Virtual Directory and setup had not been completed.
How could i resolve this Rolling Back error due to Virtual Directory ?
With which application of install shield this issues is connected ?
You need to find out what the actual error is that is causing the rollback to occur.
To do this, you'll want the installer to create a log for you.
You can do this by running the exe like this:
setup /V"/L*v c:\everything.log"
Then, look through the log file and find out where it decides to rollback (searching for "rollback", then looking just above that should get you close.)

Resources