NX for Angular preventing certain operations from running? - node.js

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.

Related

asdf fails node install with: permission denied error, how to grant it permission?

When I try to install a node version with asdf-vm, I get the following error message:
Trying to update node-build... ok
mkdir: cannot set permissions '/tmp': Permission denied
node-build: TMPDIR=/tmp is set to a non-accessible location
Try setting TMPDIR to some directory that the installer can write to (it's running as you so anywhere you can write to should work).
For example: export TMPDIR=~/tmp/.
You may also want to report this issue to the maintainers of the asdf-nodejs plugin as the temp dir logic should work out of the box on all supported systems.

ElectronJS: Operation not permitted

I've been developing an Electron app for Linux. The problem is: I can't execute an instruction because of this:
Error: socket: Operation not permitted
This might mean it needs sudo permissions. But since it is a desktop app, and I want to avoid this when I'll distribute it, is there a way to bypass this error, to execute it without sudo or automatically use it, in both development and production mode? If not, can I write a message which says it requires admin execution when I open its AppImage?
#crimson589
If I run dev mode with sudo npm run electron:serve it returns Error: Failed to get 'appData' path. If I run the AppImage with sudo, it works.

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.

Electron and NodeJS is unable to write logs to a file

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

Node fs Error: EPERM: operation not permitted, open

I get this error in my app:
Error: EPERM: operation not permitted, open 'C:\Program Files
(x86)\Full Menu\db\main.json'
The app I have is built with electron-boilerplate. I am using this function to get the path to the root of the app:
path.dirname(process.execPath)
And this is the script that writes the file:
fs.writeFile(apath + '/db/' + elem + '.json', JSON.stringify(results)
I know what the problem is: permissions. But how could I get this working without running the app as an administrator?
For the benefit of searchers; I has this error. I added full permissions for Everyone as a test, but that didn't fix it. The issue was that the file was set to readonly (by source control).
Unchecking the readonly option in the file properties fixed the issue.
On my Windows 10 machine, I encountered this error when running an old Node JS project. I think Node version 10.16.
In any case, it was trying to modify a dotfile in my project. Be sure that the file isn't hidden on Windows. After unchecking the hidden option in the file properties pop up. Everything worked.
So to fix:
Right click file in Windows Explorer
Select properties
Uncheck Hidden
Click Ok
Re-run your command.
If you have the file that you can't open or modify mounted as a volume in docker restarting docker should fix the issue.
i had to run the node command prompt as administrator and that fixed the issue.
I face this issue when I was deleting a file/folder.
Solution:
Just restart your code editor/ terminal
Or
Restart your computer
If you are facing this issue on Windows 10, then please try the following:
Uncheck readonly options for the folder (if read-only reverts, login as administrator)
Open terminal as administrator (if you are facing this issue on terminal)
Switch off ransomware folder protection
Change chmod of the folder
Check if the folder is hidden or not
Disable antivirus protection (temporarily) and try this
Or move your project folder somewhere else, where antivirus ransomware protection is disable.
If nothing above works, then try the following:
https://appuals.com/how-to-fix-folder-keeps-reverting-to-read-only-on-windows-10/.
Hope this would of help.
I think that you must change the permissions recursively to the file so the user executing your script can read / write this file.
https://fr.wikipedia.org/wiki/Chmod
Restarting my computer fixed this problem for me.
I had this issue too. I'm using TFS (or VSO, Azure DevOps, etc.) for source control. I was trying to compile from .scss to .css and it couldn't open my .css. I just needed to right-click on my .css file and Check Out for Edit...
I had the error because i have already open the file before
var stream = fs.createWriteStream(outputFileName, {flags:'a'})
var output = fs.createWriteStream(outputFileName, {flags:'a'})
this is not an exact answer but may help:
i think if you want to read or readSync a file that doesn't exist you will encounter an EPERM error...
in many programming languages, any permission related error may not
directly means an actual permission issue
for example in PHP Folders (not files) must delete by php rmdir() method but if you want to do that with unlink() , u will encountered with a wrong Warning message that says "permission denied"
I was facing the same problem using the following software:
Windows 10
GitBash
Node v19
I was able to solve it opening GitBash as admin
I had the same problem, when i tried to create and write to a file using NodeJS. I thought it had to do with my windows file/folder access permissions, but after restarting my computer and running the code again, I still got the same error.
However, this time around my antivirus gave me a pop-up message also, stating that it blocked permission for Node.exe to write or open files. So once I flagged Node.exe as safe for my anti-virus program (Avast).
It worked for me. Disabling my antivirus could've also temporarily fixed it, I guess.
If you use windows 10, you must turn off Ransomware protection. Ransomware protection will prevent all folder and file changes.You can turn off it in Windows Security Center. See screenshot below:

Resources