Error: EPERM: operation not permitted, unlink when running npm publish - node.js

When running npm publish I get the error
Error: EPERM: operation not permitted, unlink 'C:\Users\U173769\AppData\Local\Temp\npm-8604-f99ed410\tmp\fromDir-f7379123\package.tgz'
I am using Windows 10 and tried running as administrator, but I get the same error.
I'm using npm#6.4.1 and node#v10.15.3

You can probably use npm login or npm adduser.

Related

nodejs will not enable corepack: operation not permitted

I have installed nodejs and i am trying to enable corepack with corepack enable but it gives me this error on windows:
Internal Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\pnpm'
Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\pnpm'
I can not find the pnpm folder is is refering to in the nodejs folder and i have tried to npm install -g pnpm which did install pnpm
how do I fix this?
Try running the cmd as administrator

EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging

I'm trying to run npm install on my project but its showing EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules.staging
I don't have root administrative access. I'am using as local user in my system and my system is windows 10
node v10.16.3
npm v6.11.3
Can any one please help me to resolve this issue. I'am requesting you guys please.
3235 error code EPERM
3236 error syscall mkdir
3237 error path C:\Program Files\nodejs\node_modules\.staging
3238 error errno -4048
3239 error Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
3239 error { [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging']
3239 error cause:
3239 error { Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
3239 error errno: -4048,
3239 error code: 'EPERM',
3239 error syscall: 'mkdir',
3239 error path: 'C:\\Program Files\\nodejs\\node_modules\\.staging' },
3239 error stack:
3239 error 'Error: EPERM: operation not permitted, mkdir \'C:\\Program Files\\nodejs\\node_modules\\.staging\'',
3239 error errno: -4048,
3239 error code: 'EPERM',
3239 error syscall: 'mkdir',
3239 error path: 'C:\\Program Files\\nodejs\\node_modules\\.staging',
3239 error parent: 'nodemon' }
3240 error The operation was rejected by your operating system.
3240 error It's possible that the file was already in use (by a text editor or antivirus),
3240 error or that you lack permissions to access it.
3240 error
3240 error If you believe this might be a permissions issue, please double-check the
3240 error permissions of the file and its containing directories, or try running
3240 error the command again as root/Administrator.
3241 verbose exit [ -4048, true ]
Try clearing the cache:
npm cache clean --force
Or
npm uninstall npm -g
npm install npm -g
Or
npm set prefix 'C:\Users\User\AppData\Roaming\npm'
The last one worked for me
run these commands:
npm uninstall -g create-react-app
npm install -g create-react-app
that's will upgrade your npx, then run
npx create-react-app my-app
Open your command line (CMD) as an admin.
Navigate to your project directory.
Install the package globally e.g nodemon or any other npm package.
This worked for me.
on windows 10 👍
From Start Menu : type "CMD" then "run as administrator"
then continue using "Node Commands"
Delete 'C:\Users\User\AppData\Roaming\npm' folder or just rename it (like to 'npm_') to be on safe side, and then run command:
npm install
this will create 'C:\Users\User\AppData\Roaming\npm' folder again.
This worked for me.
Run
npm cache clear
npm install npm -g
If you run the command npm cache clear get error, it means you don't have npm installed yet, just run the following command: npm install npm -g
Then close command prompt or visual studio code and run it again to take effect
Today we ran into the same problem. It turned out that there was a environment variable set:
NPM_CONFIG_PREFIX=C:\Program Files\Nodejs
Removing this environment variable fixed the problem fo us.
I solve this issue...
Firstly you change your drive
c drive change make new drive D and then run your command
D:\nodejs> vue create hello-world
this is what worked for me

npm install failed with Error: EPERM: operation not permitted, unlink '\node_modules'

I try to run "npm install" command in CMD ["node_modules" is inside C drive] but installation failing with below error.
OS :Windows 10.
Node JS version: 6.9.0.
Error: EPERM: operation not permitted, unlink.
Goal: To run AngularJs project.
CMD command
npm install -- no optional;
PS C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular> npm install --no-optional
npm ERR! path C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js'
npm ERR! [Error: EPERM: operation not permitted, unlink 'C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js']
{
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink ' +
npm ERR! "'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\arunk\AppData\Roaming\npm-cache\_logs\2019-05-22T19_01_22_659Z-debug.log
I had the same problem and tried a lot of different things. This solved my problem:
1 - Uninstall NodeJs
2 - Delete folders 'npm' and 'npm-cache' from AppData/Roaming
3 - Deactivate firewall and all antivirus (including Windows Defender)
4 - Reboot the system
5 - Open command prompt as administrator and execute 'npm install'
Like you I have wasted much time trying to get 'npm install' to install Angular projects from its 'project.json' file and received similar error messages that are unhelpful; Recently I installed 'yarn' and this does a much better job of populating the 'node_modules' folder and it also generates more useful error and warning messages in the process.
Try the following steps:
Install 'Yarn' - go to it's website and download the installer for your operating system.
Got to your project directory (the one containing 'project.json')
enter the command 'yarn' and wait. This will perform the same function
as 'npm install', however it will generate fewer messages but the ones
it does will be more pertinent.
I hope this helps.
I was using yarn to install axios and got the same error, but I figured out that this error is not peculiar to axios since the same thing happens with all other packages.
Killing all running node process worked for me.
Perhaps a problem with the file system.
Check your C drive with the windows verification tool (right click on the C: -> Properties -> Tools -> Check). Repair the errors if it's needed.
It worked for me. I write here this solution for people (like me) with similar issue.
Similar problem can also happen if you try to uninstall a dependency while in another terminal window you're using
ng serve
Simply stop that operation and only then you can uninstall it.
Please try following steps:
check your antivirus status is enable or disable
disable your antivirus during the installation.
I hope this helps. It worked for me.

Npm install angular/cli error EPERM Operation not permitted

4399 error Error: EPERM: operation not permitted, unlink
'C:\Users\deven\AppData\Roaming\npm\node_modules.staging\tmp-5fcc012e\README.md'
4399 error { Error: EPERM: operation not permitted, unlink
'C:\Users\deven\AppData\Roaming\npm\node_modules.staging\tmp-5fcc012e\README.md'
4399 error cause: 4399 error { Error: EPERM: operation not
permitted, unlink
'C:\Users\deven\AppData\Roaming\npm\node_modules.staging\tmp-5fcc012e\README.md'
4399 error errno: -4048, 4399 error code: 'EPERM', 4399
error syscall: 'unlink', 4399 error path:
'C:\Users\deven\AppData\Roaming\npm\node_modules\.staging\tmp-5fcc012e\README.md'
}, 4399 error stack: 'Error: EPERM: operation not permitted, unlink
\'C:\Users\deven\AppData\Roaming\npm\node_modules\.staging\tmp-5fcc012e\README.md\'',
4399 error errno: -4048, 4399 error code: 'EPERM', 4399 error
syscall: 'unlink', 4399 error path:
'C:\Users\deven\AppData\Roaming\npm\node_modules\.staging\tmp-5fcc012e\README.md',
4399 error parent: '#angular/cli' } 4400 error The operation was
rejected by your operating system. 4400 error It's possible that the
file was already in use (by a text editor or antivirus), 4400 error or
that you lack permissions to access it. 4400 error 4400 error If you
believe this might be a permissions issue, please double-check the
4400 error permissions of the file and its containing directories, or
try running 4400 error the command again as root/Administrator (though
this is not recommended). 4401 verbose exit [ -4048, true ]
Since you're using Windows, you have to launch the terminal as administrator and retry should work.
It seems like this is a problem with npm. Try deleting your node_modules folder and running npm install again. This should fix the problem.
It may be possible that your package.json is open in some editor. Close it and then run the npm command again.
Try to uninstall the CLI using:
npm uninstall -g #angular/cli
and reinstall using:
npm install -g #angular/cli
and also try to update npm to latest version
npm cache clean --force
npm install -g npm#latest
It solved for me when I made this: Right-click on -What ever program I use- and select Run as Administrator.
Personally I made it on PowerShell, but I assume that it works this way on any program
Launch your code editor (eg.. Visual Studio Code) as Administrator.
npm install -g #vue/cli.
vue create yourprojectname.
Please try following steps:
Delete node_modules
Do npm cache clean --force
Restart the PC
Try again npm install, now modules will install without any issues
(optional) - If you are behind VPN and not using any private registry , exit VPN and do npm install after restarting pc
I had opened the project in multiple terminals. Later after closing all the respective terminals and running 'npm i', things started to work well.

installing PhantomJS on Windows: rolling back Error: EPERM, unlink phantomjs.exe

I try to install karam/Jasmine/PhantomJS on my Windows machine.
It was installed before in a different project. I have my proxies set up nicely, but it throws a weird error.
npm ERR! error rolling back Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR! error rolling back karma-phantomjs-launcher#0.1.4 { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR! error rolling back errno: 50,
npm ERR! error rolling back code: 'EPERM',
npm ERR! error rolling back path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
npm ERR! Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe'
npm ERR! { [Error: EPERM, unlink 'C:\xampp\htdocs\acme\node_modules\karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: 'C:\\xampp\\htdocs\\acme\\node_modules\\karma-phantomjs-launcher\\node_modules\\phantomjs\\lib\\phantom\\phantomjs.exe' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
So I deleted the phantomjs.exe and tried again.
I executed the console as admin and retried.
I deleted the whole node_modules folder and installed again
I used npm cache clear
I deactivated my A/V as suggested here
... same error.
Why would npm try to delete the PhantomJS during install? As I said, I deleted it before. So I have no node_modules folder, execute npm install and it creates the phantomjs.exe and then fails with said error.
Any ideas anyone?
I had a similar issue that ultimately seemed to have been caused by still having an errant phantomjs.exe process running while I was performing an npm update.
While it seems unlikely that this may have been the same cause as what you were experiencing, it seems to be at the very least one of the ways to receive this same error message.
I was able to resolve by opening up Windows Task Manager (Ctrl+Shift+Esc), finding phantomjs.exe in the Processes tab, and using 'End Process' on it.

Resources