projen: Not working on Windows

Get the following - which I think is related to the paths not being correct

npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\.xmlbuilder2.DELETE\node_modules\@types
npm ERR! dest C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\xmlbuilder2\node_modules\@types
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\.xmlbuilder2.DELETE\node_modules\@types' -> 'C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\xmlbuilder2\node_modules\@types'
npm ERR!  [OperationalError: EPERM: operation not permitted, rename 'C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\.xmlbuilder2.DELETE\node_modules\@types' -> 'C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\xmlbuilder2\node_modules\@types'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, rename 'C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\.xmlbuilder2.DELETE\node_modules\@types' -> 'C:\Users\david\AppData\Roaming\npm-cache\_npx\10136\node_modules\projen\node_modules\xmlbuilder2\node_modules\@types'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     path: 'C:\\Users\\david\\AppData\\Roaming\\npm-cache\\_npx\\10136\\node_modules\\projen\\node_modules\\.xmlbuilder2.DELETE\\node_modules\\@types',
npm ERR!     dest: 'C:\\Users\\david\\AppData\\Roaming\\npm-cache\\_npx\\10136\\node_modules\\projen\\node_modules\\xmlbuilder2\\node_modules\\@types'
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, rename 'C:\\Users\\david\\AppData\\Roaming\\npm-cache\\_npx\\10136\\node_modules\\projen\\node_modules\\.xmlbuilder2.DELETE\\node_modules\\@types' -> 'C:\\Users\\david\\AppData\\Roaming\\npm-cache\\_npx\\10136\\node_modules\\projen\\node_modules\\xmlbuilder2\\node_modules\\@types'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\david\\AppData\\Roaming\\npm-cache\\_npx\\10136\\node_modules\\projen\\node_modules\\.xmlbuilder2.DELETE\\node_modules\\@types',
npm ERR!   dest: 'C:\\Users\\david\\AppData\\Roaming\\npm-cache\\_npx\\10136\\node_modules\\projen\\node_modules\\xmlbuilder2\\node_modules\\@types',
npm ERR!   parent: 'projen'
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\david\AppData\Roaming\npm-cache\_logs\2021-01-17T09_59_49_956Z-debug.log
Install for [ 'projen@latest' ] failed with code 4294963248

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (15 by maintainers)

Most upvoted comments

I had the same problem. I got projen working in Windows 10 with Node 14.15.4 LTS by using a project-local node_modules. This is what I did:

PS E:\Proj> yarn init
PS E:\Proj> yarn add --dev projen
PS E:\Proj> yarn projen new awscdk-construct

Ok I’m able to reproduce the issue on node v14 as well. It can also be reproduced by running npm install -g projen. Unfortunately I’m not sure how to fix it yet - part of the difficulty is that it’s difficult to test “npm install” using local versions of projen with changes. That said, it appears to be caused by the addition of the xmlbuilder2 library in projen 0.13.10 (commit).

The current workarounds I’ve found:

  • Use node v15.x.x or above
  • Install projen globally using yarn global add projen and run projen new <project-type> to bootstrap your project. Then you can run npx projen commands inside the project directory normally. Afterwards, you’re free to remove the global projen command if you’d like to avoid polluting the global namespace via yarn global remove projen.

I’m not really familiar with this kind of bug, but I’d like try pinning different versions of xmlbuilder2 or its dependencies and see if that fixes the bug. Specifically, xmlbuilder2 has a runtime dependency on @types/node which could be causing a conflict of some kind.