Error: EPERM: operation not permitted, rename

I’m struggling with cordova/npm clis errors.
I noticed my Ionic1 application developed 5 months ago (which use crosswalk-webview) works with Android 6 but crash with Android 7 (it seems a known bug).

  • I tried to remove and re-add crosswalk-webview:
    cordova plugin rm cordova-plugin-crosswalk-webview
    cordova plugin add cordova-plugin-crosswalk-webview
    I get an npm error on adding the plugin:
    npm verb stack Error: EPERM: operation not permitted, rename...

  • the build fails:
    ionic cordova build --release android with the same error:
    Error: EPERM: operation..

  • since several plugin are outdated, I thought to remove and re-add the whole platform android
    cordova platform rm android
    Almost 1 hour later the command is still stuck so I terminated it.

Now if I try to add android as platform I get an error:
Error: EPERM: operation not permitted, rename...

Now my project is pretty broken: no platform and no way to build it…and I’m in very hurry about that…

I tried to downgrade npm, I tried the following 5.6.0, 5.5.1, 5.4.2, 5.3.0, 5.0.0, 4.6.0.
I reinstalled node, cordova, ionic, I cleared npm cache.
I do not solved. It’s clearly an NPM issue, maybe here somewhere knows how to solve…

At the current state, if I try:
cordova platform add android
I get:
Error: EPERM: operation not permitted, rename 'C:\nodejs\myapp\node_modules\.staging\cordova-android-78ae6d2a\node_modules\cordova-registry-mapper'

Simply NPM is became a huge blob of unstable code. I always use yarn in my nodejs (non Ionic) projects, but in this case Cordova seems still on npm…