'permission denied when using npm install

I have this pipeline

pipeline {
   agent none
   stages {
      stage("ScrapData") {
         agent {
            label 'master'
         }
         steps {
            bat '''
               cd folder
               call npm i puppeteer
               
               cd ..
               call node myfile.js 
            '''
         }
      }

But it is throwing the following exception:

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\node_modules\.puppeteer.DELETE\.local-chromium\win64-756035\chrome-win\chrome.exe
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\node_modules\.puppeteer.DELETE\.local-chromium\win64-756035\chrome-win\chrome.exe'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\node_modules\.puppeteer.DELETE\.local-chromium\win64-756035\chrome-win\chrome.exe'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\node_modules\.puppeteer.DELETE\.local-chromium\win64-756035\chrome-win\chrome.exe'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'C:\\Users\\rpaadmin\\.jenkins\\workspace\\ikinciyeni\\generic_scrapper\\node_modules\\.puppeteer.DELETE\\.local-chromium\\win64-756035\\chrome-win\\chrome.exe'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\rpaadmin\\.jenkins\\workspace\\ikinciyeni\\generic_scrapper\\node_modules\\.puppeteer.DELETE\\.local-chromium\\win64-756035\\chrome-win\\chrome.exe',
npm ERR!   parent: 'generic_scrapper'
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\rpaadmin\AppData\Roaming\npm-cache\_logs\2020-07-10T09_29_41_842Z-debug.log
internal/modules/cjs/loader.js:960
  throw err;
  ^

Error: Cannot find module 'puppeteer

How do I solve this issue? I'm not sure about how to solve it. I am not sure about how to solve it. It was working fine before but now it has stopped working.



Solution 1:[1]

To fix this I had to reboot windows, manually delete the puppeteer folder from node_modules, then install it again. Seems ok since

NB I couldn't delete it without a reboot, it wouldn't let me change permissions on the folder

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tony