phoenixframework / phoenix

Peace of mind from prototype to production
https://www.phoenixframework.org
MIT License
21.26k stars 2.87k 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

PhillippOhlandt commented 7 years ago

Hey,

that is not directly Phoenix related. Something with your nodejs/npm setup is broken. Your app will continue to work, you are just not able to compile your frontend assets right now.

bxqgit commented 7 years ago

@PhillippOhlandt Well, is it a common problem for Phoenix frontend assets? I'm pretty sure everything is fine with NodeJS/npm, because other products, that use them - work just fine.

PhillippOhlandt commented 7 years ago

It seems to be a common problem on Windows. When you google the error, you see a lot of issues on various NodeJS libs and frameworks. I am sure I had this problem too some day, but I can't remember how I fixed it. Maybe you can browse through the issues and look for a solution until someone else replies with one here.

https://www.google.com/search?source=hp&q=npm+Error%3A+EPERM%3A+operation+not+permitted%2C+unlink&oq=npm+Error%3A+EPERM%3A+operation+not+permitted%2C+unlink&gs_l=psy-ab.3..0i22i30k1l2.917.917.0.1159.1.1.0.0.0.0.90.90.1.1.0....0...1.1.64.psy-ab..0.1.90.8mi0F3pMV1E

bxqgit commented 7 years ago

@PhillippOhlandt

Looks like the problem is with brunch npm package. When I run:

npm install -g brunch

I get the same error.

OvermindDL1 commented 7 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.

bxqgit commented 7 years ago

@OvermindDL1 No antivirus at all. Microsoft protection apps are also turned off.

webdeb commented 7 years ago

It looks like a filesystem permission issue. look here the same error

https://blogs.msdn.microsoft.com/matt-harrington/2012/02/23/how-to-fix-node-js-npm-permission-problems/

Oluwafemi-Olayemi commented 7 years ago

uninstall all npm modules and re-install with npm install --no-bin-links. I had same problem on windows. read this for more info

OvermindDL1 commented 7 years ago

uninstall all npm modules and re-install with npm install --no-bin-links. I had same problem on windows. read this for more info

I'm curious, as I'm not a heavy windows user (only touch that mess at work), why is it working for me?

Oluwafemi-Olayemi commented 7 years ago

I stumble on the knowledge of --no-bin-links doing laravel projects on windows and always have problem with npm commands. So my rule of working on windows is "run npm with that switch" and on any other OS without it. If you have been using npm without the switch, then most likely you are yet to install a module that will fail doing so.

OvermindDL1 commented 7 years ago

I stumble on the knowledge of --no-bin-links doing laravel projects on windows and always have problem with npm commands. So my rule of working on windows is "run npm with that switch" and on any other OS without it. If you have been using npm without the switch, then most likely you are yet to install a module that will fail doing so.

Do you have such a module that I can test with then? I use quite a load from brunch to bucklescript to many others and apparently over 700 (holy...) in between based on the dependency graph... >.>

chrismccord commented 7 years ago

@bxqgit have you made any progress on this? Did you try running npm install --no-bin-links within the assets directory?

bxqgit commented 7 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
chrismccord commented 7 years ago

Great to hear you're up and running! Thanks for following up

DanielCaspers commented 7 years ago

If you have private registries you forgot to configure, don't forget about npm adduser or npm login. Alternatively if that is the case, look over the ~/.npmrc file to make sure this makes sense.

I was tracing this down thinking this was a perms issue or windows issue until I found this in another git issue.

veton commented 6 years ago

Found this thread expiriencing similar issue with npm publish <tarball>

Solved it by logging into npmjs: npm login

Would be great to have more descriptive message for failed authentication, if this is the case.

vaibhav4143 commented 6 years ago

We shoud off the Antivirus... Thank you OvermindDL1

OvermindDL1 commented 6 years ago

We shoud off the Antivirus... Thank you

No problem. For note you shouldn't need to completely shut off the AV (well, for some of them, others still read everything, even ignored areas) if you just add the whole project path to it's ignored locations. :-)

vaibhav4143 commented 6 years ago

Facing problem::while installaion of ionic... It shows python not installed.....could you help me to solve this

On 16 Jan 2018 9:10 pm, "OvermindDL1" notifications@github.com wrote:

We shoud off the Antivirus... Thank you

No problem. For note you shouldn't need to completely shut off the AV (well, for some of them, others still read everything, even ignored areas) if you just add the whole project path to it's ignored locations. :-)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/phoenixframework/phoenix/issues/2464#issuecomment-358002533, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-94WkRmKRWl5ptcKlDHTj0xwZw1ap1ks5tLMLhgaJpZM4PFFru .

OvermindDL1 commented 6 years ago

Facing problem::while installaion of ionic... It shows python not installed.....could you help me to solve this

Elixir, nor Phoenix, use Python anywhere, so I'm unsure how it would relate to the phoenix repository. :-) No clue what ionic is, perhaps check its docs?

vaibhav4143 commented 6 years ago

Thank you

On 16 Jan 2018 9:33 pm, "OvermindDL1" notifications@github.com wrote:

Facing problem::while installaion of ionic... It shows python not installed.....could you help me to solve this

Elixir, nor Phoenix, use Python anywhere, so I'm unsure how it would relate to the phoenix repository. :-) No clue what ionic is, perhaps check its docs?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/phoenixframework/phoenix/issues/2464#issuecomment-358011496, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-94ZR-SLOTAKwR0h3l50jKNX-F1XOBks5tLMhngaJpZM4PFFru .

kchrs commented 6 years ago

If you are on windows you have to start your node application having adminsitration rights while opening your terminal (dos) window. Right click the terminal icon and select "run as an adminstrator"

vaibhav4143 commented 6 years ago

Yes brother. Thank you

On 13 Feb 2018 6:59 pm, "kchrs" notifications@github.com wrote:

If you are on windows you have to start your node application having adminsitration rights while opening your terminal (dos) window. Right click the terminal icon and select "run as an adminstrator"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/phoenixframework/phoenix/issues/2464#issuecomment-365266456, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-94aGbu8HftdipCtQbdlszRhGhjjOjks5tUY4cgaJpZM4PFFru .

LoganSimonsen commented 6 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.

vaibhav4143 commented 6 years ago

Thank you

On 26 Feb 2018 10:13 pm, "Logan Simonsen" notifications@github.com wrote:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/phoenixframework/phoenix/issues/2464#issuecomment-368565759, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-94b7fv3uCEM0PrtpdiN03u3NVzoL4ks5tYt8lgaJpZM4PFFru .

timlorepublic commented 6 years ago

Thank you @LoganSimonsen . Your solution works for me

franciscop-invast commented 6 years ago

I had the same issue with create-react-app and chokidar. I had node running with npm start in a different console, so after closing that the error went away. For me it was the same issue as @LoganSimonsen mentions.

Note: I'm used to Linux where this would not have been an issue, that's why I didn't catch it at first and it took me an embarrassing amount of time to find the problem.

Jindu0506 commented 6 years ago

I was facing the same issue. I moved my project in another folder and then tried running the same command. It worked. It indicates it is something in relation with permission.

vidurajith-darshana commented 6 years ago

@veton Thanks..You solved my problem!

vaibhav4143 commented 6 years ago

It's ok brother. Do well

On Sun 22 Jul, 2018, 1:02 PM vidurajith-darshana, notifications@github.com wrote:

@veton https://github.com/veton Thanks..You solved my problem!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/phoenixframework/phoenix/issues/2464#issuecomment-406847198, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-94e8drCELUcHUaulajZvpdjE4ngeWks5uJCp1gaJpZM4PFFru .

enoksaju commented 6 years ago

Thank you @LoganSimonsen this working for me too

schellack commented 6 years ago

I tried using Task Manager to kill background node processes. For me I finally had to reboot to ensure that all background processes were killed.

ghost commented 6 years ago

KILL THEM ALL @schellack

I tried using Task Manager to kill background node processes. For me I finally had to reboot to ensure that all background processes were killed.

Enalmada commented 5 years ago

I too just ran into this for the first time trying to update my expo-cli npm install -g expo-cli. I killed all the node processes in task manager to no avail (neither did stopping antivirus). Restarting windows did work.

Abilandou commented 5 years ago

command ran: expo init new_project_name expected: successful creation of project instead got the error below.

ERROR:

npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Godlove\Desktop\ReactNative\thirdReactApp\node_modules.staging\react-native-4cfe71f8\RNTester\RNTesterIntegrationTests\ReferenceImages\RNTester-js-RNTesterApp.ios\testTextExample_1@2x.png' npm ERR! { [Error: EPERM: operation not permitted, unlink 'C:\Users\Godlove\Desktop\ReactNative\thirdReactApp\node_modules.staging\react-native-4cfe71f8\RNTester\RNTesterIntegrationTests\ReferenceImages\RNTester-js-RNTesterApp.ios\testTextExample_1@2x.png'] npm ERR! cause: npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\Godlove\Desktop\ReactNative\thirdReactApp\node_modules.staging\react-native-4cfe71f8\RNTester\RNTesterIntegrationTests\ReferenceImages\RNTester-js-RNTesterApp.ios\testTextExample_1@2x.png' npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR! path: npm ERR! 'C:\Users\Godlove\Desktop\ReactNative\thirdReactApp\node_modules\.staging\react-native-4cfe71f8\RNTester\RNTesterIntegrationTests\ReferenceImages\RNTester-js-RNTesterApp.ios\testTextExample_1@2x.png' }, npm ERR! stack: npm ERR! 'Error: EPERM: operation not permitted, unlink \'C:\Users\Godlove\Desktop\ReactNative\thirdReactApp\node_modules\.staging\react-native-4cfe71f8\RNTester\RNTesterIntegrationTests\ReferenceImages\RNTester-js-RNTesterApp.ios\testTextExample_1@2x.png\'', npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR! path: npm ERR! 'C:\Users\Godlove\Desktop\ReactNative\thirdReactApp\node_modules\.staging\react-native-4cfe71f8\RNTester\RNTesterIntegrationTests\ReferenceImages\RNTester-js-RNTesterApp.ios\testTextExample_1@2x.png' } 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\Godlove\AppData\Roaming\npm-cache_logs\2019-01-13T11_25_48_952Z-debug.log [03:25:49] Process exited with non-zero code: 4294963248 [03:25:49] Set EXPO_DEBUG=true in your env to view the stack trace.

have tried all the solutions above but none works for me, running windows 10. Please help. Thanks.

dalhorinek commented 5 years ago

@Abilandou I don't think this is related to Phoenix, you should probably post it in here https://github.com/expo/expo

Abilandou commented 5 years ago

Ok thanks

Abilandou commented 5 years ago

Thanks @dalhorinek for the link, problem solved

ManfredLange commented 5 years ago

uninstall all npm modules and re-install with npm install --no-bin-links. I had same problem on windows. read this for more info

Equally you can use npm ci --no-bin-link where you'd use npm ci otherwise. This worked in my case on Windows.

bbmattieu9 commented 5 years ago

The solution above does not work for me. i have a sailsjs project and i tried to upload an image in to the assets/img folder but i get this Error: EPERM: operation not permitted, unlink './assets/img/' error. I do not know what to do about this error.

OvermindDL1 commented 5 years ago

@bbmattieu9 Might be best to ask this either on the elixir forums or on a node-specific area, but at the very least what is your OS? As long as it's not windows that error is simple to fix, if it is windows well thats more of node assuming unix'y style system and can have a huge variety of different causes, but shouldn't be a phoenix issue in either case.

mtx-z commented 5 years ago

To me was simple: I tried to run npm install while npm run watch was still running.

ChioukhLyes 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.

If you use an IDE, kill running instances to.

VimLeSai commented 5 years ago

Found this thread expiriencing similar issue with npm publish <tarball>

Solved it by logging into npmjs: npm login

Would be great to have more descriptive message for failed authentication, if this is the case.

@veton i have publish my pacakge and sometimes when install it for updates it causes this problem how can it be problem with publish ? and if i use --no-bin-links it's works

CHANDRAMOHANnegi commented 5 years ago

`Creating a new React app in C:\Users\CM\Downloads\react\github-profile. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...

npm ERR! path C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806 npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall lstat npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806' npm ERR! { [Error: EPERM: operation not permitted, lstat 'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806'] npm ERR! cause: npm ERR! { Error: EPERM: operation not permitted, lstat 'C:\Users\CM\AppData\Roaming\npm-cache_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806' npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'lstat', npm ERR! path: npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806' }, npm ERR! stack: npm ERR! 'Error: EPERM: operation not permitted, lstat \'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806\'', npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'lstat', npm ERR! path: npm ERR! 'C:\Users\CM\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\36\c6\c3e97514319bc1c6d40026e58325e782e1016c996b1fa335b10893d67f7339e4af62bb688c0da2aaca839d4c9d51e2eb015eec65545008a3cad93d00f806', npm ERR! parent: 'postcss-image-set-function' } 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 thenpm 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\CM\AppData\Roaming\npm-cache_logs\2019-03-22T10_27_19_722Z-debug.log

Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. Deleting generated file... node_modules Deleting generated file... package.json Deleting github-profile/ from C:\Users\CM\Downloads\reactDone.``

`

i was facing similar error but i tried to run create-react-app command many times and finally it was created , this was the problem with my internet connection. check your inernet connection

sudip03 commented 5 years ago

Thanks @dalhorinek for the link, problem solved

Please can you tell me how you solved this. I am having same issue. It will be a great help.

ThulasiA 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.

vaibhav4143 commented 5 years ago

That's great

On Thu 18 Apr, 2019, 11:27 AM Thulasi, notifications@github.com wrote:

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 https://github.com/LoganSimonsen . The idea worked for me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/phoenixframework/phoenix/issues/2464#issuecomment-484366508, or mute the thread https://github.com/notifications/unsubscribe-auth/ACX33YICBHLX2DOTPYVWMQ3PRAEU7ANCNFSM4DYULLXA .

danieldanielecki commented 5 years ago

It could be simply due to the reason you had opened node_modules in file explorer.

alinmateut commented 5 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.

Yep! It was because I had Webstorm open