Search code examples
node.jsnpmnpm-installlerna

operation not permitted error npm while running lerna bootstrap -- hoist command on windows


Whenever I am running lerna bootstrap --hoist or lerna bootstrap I am getting the following error on my windows machine.

I have already tried npm login and force cleaned the npm cache but nothing seems to be working.

npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\Devfolio_work\ethglobal-devfolio\node_modules\.staging\typescript-ebd093cf\lib\typescriptServices.js'
npm ERR!  { [Error: EPERM: operation not permitted, unlink 'E:\Devfolio_work\ethglobal-devfolio\node_modules\.staging\typescript-ebd093cf\lib\typescriptServices.js']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, unlink 'E:\Devfolio_work\ethglobal-devfolio\node_modules\.staging\typescript-ebd093cf\lib\typescriptServices.js'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'unlink',
npm ERR!      path:
npm ERR!       'E:\\Devfolio_work\\ethglobal-devfolio\\node_modules\\.staging\\typescript-ebd093cf\\lib\\typescriptServices.js' },
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, unlink \'E:\\Devfolio_work\\ethglobal-devfolio\\node_modules\\.staging\\typescript-ebd093cf\\lib\\typescriptServices.js\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path:
npm ERR!    'E:\\Devfolio_work\\ethglobal-devfolio\\node_modules\\.staging\\typescript-ebd093cf\\lib\\typescriptServices.js',
npm ERR!   parent: 'root' }
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\hp\AppData\Roaming\npm-cache\_logs\2019-01-09T16_55_24_342Z-debug.log

lerna.json

{
  "packages": [
    "packages/*"
  ],
  "version": "independent"
}

My Environment

lerna --version 3.5.1

npm --version 6.4.1

node --version 10.5.0

OS Version

Windows 10 1709


Solution

  • I finally found a solution; it seems to be an issue with Windows. Just run the command in an admin command prompt in your current working directory and it would work.