phoenixframework / phoenix

Peace of mind from prototype to production
https://www.phoenixframework.org
MIT License
21.44k stars 2.88k forks source link

Error: EPERM: operation not permitted, unlink #2464

Closed bxqgit closed 7 years ago

bxqgit commented 7 years ago

Expected behavior

No errors while executing npm install in ./assets directory.

Actual behavior

All commands are run as root/Administrator. I run mix phx.new hello, which suggests to run cd hello and cd assets && npm install && node node_modules/brunch/bin/brunch build afterwards.

When I run npm install in ./assets directory, I get the following error:

npm ERR! path c:\prj\hello\assets\node_modules\nan\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'c:\prj\hello\assets\node_modules\nan\package.json'
npm ERR!  { Error: EPERM: operation not permitted, unlink 'c:\prj\hello\assets\node_modules\nan\package.json'
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'c:\\prj\\hello\\assets\\node_modules\\nan\\package.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'c:\\prj\\hello\\assets\\node_modules\\nan\\package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\foo\AppData\Roaming\npm-cache\_logs\2017-08-28T21_19_41_885Z-debug.log

Is it ok? Does it break my app somehow?

Environment

raboija commented 5 years ago

This worked for me: ctrl + Alt + Delete, Task Manager, Find all running instances of node server and kill them. install your packages.

basic idea is that your node server keeps running in the background even after you think you've closed it in the console and it is accessing all your node files.

THANK YOU

lynxlangya commented 5 years ago

@LoganSimonsen Oh Thanks Very much, This is very helpful to me.

mkrishna4u commented 5 years ago

its look like windows issue and wait for 1 to 2 minutes and try again then window will release the lock on the file/folder. To me it happens time to time.

DutchKevv commented 5 years ago

Visual studio code's (VS code) integrated terminal created problems for me. For some reason the editor hijacks the files, locking them and so this permission error shows.

If I do it through a standalone terminal, it just works.

Could be windows only problem though, I never had problems with it on linux, also using vscode.

heads up to @jarvar

capt-morgan commented 5 years ago

Visual studio code's (VS code) integrated terminal created problems for me. For some reason the editor hijacks the files, locking them and so this permission error shows.

If I do it through a standalone terminal, it just works.

Could be windows only problem though, I never had problems with it on linux, also using vscode.

heads up to @jarvar

I have a similar experience. Been getting the same error message when bootstrapping lerna from GitBash integrated in WebStorm. Then tried standalone Windows Command and it worked like a charm.

rashmimilan commented 5 years ago

This worked for me: ctrl + Alt + Delete, Task Manager, Find all running instances of node server and kill them. install your packages. basic idea is that your node server keeps running in the background even after you think you've closed it in the console and it is accessing all your node files.

Thanks a ton @LoganSimonsen . The idea worked for me.

Thank you! I followed above steps to resolve the issue.

kuromukira commented 5 years ago

Can't seem to solve this tho. I have restarted my PC several times and still no luck. I also changed the folder permissions.

zzhangpurdue commented 5 years ago

most likely a running node.js application is using it. Make sure to close all of the node.js application.[solved]

dositejg commented 4 years ago

In my case something got messed up with node_modules and package-lock.json, removing them worked for me. To remove node_modules through command line, navigate to your project folder and write rm -R node_modules

jerry-santana commented 4 years ago

I have tried EVERYTHING in this page and nothing has worked for me! When I run the command yarn upgrade @[packagename] it fails immediately with EPERM: operation not permitted. What should I do?

rishav394 commented 4 years ago

Simply closing vscode fixed this for me. Something else might have a lock on some of the node packages. It is the cause of this issue. Example, you might be running the react development server and it creates a lock on the create-react-app files. This can cause the issue.

sabdelkhaliq commented 4 years ago

This worked for me: ctrl + Alt + Delete, Task Manager, Find all running instances of node server and kill them. install your packages.

basic idea is that your node server keeps running in the background even after you think you've closed it in the console and it is accessing all your node files.

Thank you! it works

DavidDolyak commented 4 years ago

Just turn off the app, install a module and run the app again. Worked for me!

shilu-stha commented 3 years ago

@chrismccord I just dropped the npm cache and everything works fine now. It's definitely the issue of npm, not Phoenix.

rd /s /q C:\Users\foo\AppData\Roaming\npm-cache
rd /s /q C:\Users\foo\AppData\Roaming\npm

Worked for me.

RxNationGaming commented 3 years ago

Plz help I got the npm err! Code EPERM on my android device I am using termux like a cmd promt

Mansouri147 commented 3 years ago

That error generally means that a file is being accessed by two different things at 'around' the same time. And 90% of those times it is because of an anti-virus or similar.

Yeah I was facing the same error and this works fine! for my case it was because I'm actually running the app (metro) and trying to update packages by running yarn

alex-shepel commented 2 years ago

That error generally means that a file is being accessed by two different things at 'around' the same time. And 90% of those times it is because of an anti-virus or similar.

It helped me when I terminated localhost. It was started with npm start.

11AA8R4 commented 2 years ago

That error generally means that a file is being accessed by two different things at 'around' the same time. And 90% of those times it is because of an anti-virus or similar.

My google drive auto-backup is accessing it then, you solved the problem for me, i gotta disable it while editing

mamonaabdullah122 commented 2 years ago

Help me i have this issue when i start the serve in angular with command of ng serve or ng serve --open then this error will be appear:Can someone help An unhandled exception occurred: Cannot find module 'electron-to-chromium/versions' Require stack:

nestorbfgo commented 2 years ago

One thing that help to resolve this problem was use npm install like admin, I was using yarn before so I dont now why happened it, but using npm install didnt cause me any problem