npm operation not permitted, rename

Norbert Kardos's Avatar

Norbert Kardos

28 Jan, 2022 12:23 PM

Today the builds in two projects started to fail with npm errors:
npm -g install npm
npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate
npm ERR! dest C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'
npm ERR! [OperationalError: EPERM: operation not permitted, rename 'C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'] {
npm ERR! cause: [Error: EPERM: operation not permitted, rename 'C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\.node-gyp.DELETE\node_modules\@tootallnate' -> 'C:\Users\appveyor\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\node_modules\@tootallnate'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\Users\\appveyor\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@tootallnate',
npm ERR! dest: 'C:\\Users\\appveyor\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@tootallnate'
npm ERR! },
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'C:\\Users\\appveyor\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\.node-gyp.DELETE\\node_modules\\@tootallnate',
npm ERR! dest: 'C:\\Users\\appveyor\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\node_modules\\@tootallnate',
npm ERR! parent: 'npm'
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.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\appveyor\AppData\Roaming\npm-cache\_logs\2022-01-28T12_17_48_444Z-debug.log
Command exited with code -4048

  1. 1 Posted by dev on 28 Jan, 2022 02:32 PM

    dev's Avatar

    The solution was to remove the npm install from the beginning:
    npm -g install npm

  2. 2 Posted by nbdevelop on 28 Jan, 2022 06:57 PM

    nbdevelop's Avatar

    I'm encountering the same issue and output as the above, with the error relating to the same package "node-gyp.DELETE\node_modules\@tootallnate"

    - the above solution, simply removing the command, does not work (unless there is explanation missing)
    - npm install builds successfully in the local environment
    - I've tried moving 'npm install' to the install stage as mentioned in https://help.appveyor.com/discussions/problems/5290-npm-error-operation-not-permited-on-renaming-a-packagetgz

    config is attached. Would appreciate any leads

  3. 3 Posted by nbdevelop on 28 Jan, 2022 07:02 PM

    nbdevelop's Avatar

    Wrongly included a modified yml above. The one causing error is attached below

  4. Support Staff 4 Posted by Feodor Fitsner on 28 Jan, 2022 10:10 PM

    Feodor Fitsner's Avatar

    @nbdevelop Are you running npm -g install npm as well?

  5. 5 Posted by nbdevelop on 31 Jan, 2022 11:51 AM

    nbdevelop's Avatar

    I'm not running npm -g install npm. Only the contents of the yml file.

  6. Support Staff 6 Posted by Feodor Fitsner on 31 Jan, 2022 05:02 PM

    Feodor Fitsner's Avatar

    You don't need to install Node with Chocolatey - it's already pre-installed on AppVeyor VMs. Try changing appveyor.yml to the following:

    version: 0.2.{build}-{branch}
    branches:
      only:
      - develop
    image: Visual Studio 2019
    install:
    - ps: Install-Product node 12
    build_script:
    - cmd: >-
        npm install
        npm run build
    test: off
    

    Also, if it dosn't help you could try removing package-lock.json.

  7. 7 Posted by nbdevelop on 31 Jan, 2022 07:23 PM

    nbdevelop's Avatar

    The above did not solve the problem, however I changed the install command to use 'ci' and removed our package-lock.json from gitignore (which I now understand is the correct way) and this solved the issue. Really appreciate the help - thank you!

    version: 0.2.{build}-{branch}
    branches:
      only:
      - develop
    image: Visual Studio 2017
    install:
    - ps: Install-Product node 12
    build_script:
    - cmd: >-
        npm ci
        npm run build
    test: off```
    
  8. Support Staff 8 Posted by Feodor Fitsner on 31 Jan, 2022 07:31 PM

    Feodor Fitsner's Avatar

    Sounds great, thanks for the update!

  9. Feodor Fitsner closed this discussion on 02 Apr, 2022 09:02 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac