angular-cli: Permission error on second build when nomodule polyfill is included

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

I’m not sure. This is the first time I’ve seen it, but I recently upgraded to Angular 8.

Description

I reproducibly get a permission error, seen below, in a clean, brand new angular project, when browserslist specifies browsers that require nomodule polyfill.

πŸ”¬ Minimal Reproduction

  1. ng new test
  2. In the new project, add to browserslist: ios_saf >= 10
  3. ng build --prod
  4. ng build --prod (again)

πŸ”₯ Exception or Error


chunk {0} runtime-es2015.24b02acc1f369d9b9f37.js (runtime) 2.83 kB [entry] [rendered]
chunk {1} main-es2015.7c221f45d48105c2ba9d.js (main) 251 kB [initial] [rendered]
chunk {2} polyfills-es2015.fd917e7c3ed57f282ee5.js (polyfills) 64.3 kB [initial] [rendered]
chunk {3} polyfills-es5-es2015.3aa54d3e5134f5b5b842.js (polyfills-es5) 223 kB [initial] [rendered]
chunk {4} styles.3ff695c00d717f2d2a11.css (styles) 0 bytes [initial] [rendered]
chunk {polyfills-nomodule-es5} polyfills-nomodule-es5.b79bfebc521ac1ea1602.js (polyfills-nomodule-es5) 372 bytes [entry] [rendered]
Date: 2019-08-30T21:28:19.886Z - Hash: c40b7c3c8a049ad41deb - Time: 12280ms
Generating ES5 bundles for differential loading...
An unhandled exception occurred: EACCES: permission denied, copyfile '/Users/karp/Documents/git/outputhashing2/node_modules/.cache/angular-build-dl/content-v2/sha512/f3/26/48b77841506560fd29c0954a8fe431f253a24b4306fd7399aaec8a09d0dcc974a357856c0b742e8e40a0ac34f406ebc3b58955f738ea327fc8e1819cd7a3' -> '/Users/karp/Documents/git/outputhashing2/dist/outputhashing2/polyfills-nomodule-es5.b79bfebc521ac1ea1602.js'
See "/private/var/folders/pf/z4z5f17x7jb0n0m44bmkhyw00000gn/T/ng-7tYGDL/angular-errors.log" for further details.

🌍 Your Environment


Angular CLI: 8.3.2
Node: 10.16.0
OS: darwin x64
Angular: 8.2.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.2
@angular-devkit/build-angular     0.803.2
@angular-devkit/build-optimizer   0.803.2
@angular-devkit/build-webpack     0.803.2
@angular-devkit/core              8.3.2
@angular-devkit/schematics        8.3.2
@angular/cli                      8.3.2
@ngtools/webpack                  8.3.2
@schematics/angular               8.3.2
@schematics/update                0.803.2
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant? Nuking node_module (and presumably just the cache dir within) and reinstalling fixes the issue for one build. Sorry to put this out there on a Friday afternoon!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 25 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Some other users also seem to experience An unhandled exception occurred: EEXIST: file already exists, copyfile

wow thanks guys! I solved it…

I was using nvm with the latest version v11.12.0…

solution was to use the stable Node!

nvm install v10.16.3
nvm use v10.16.3

I had the same problem and after removing node_modules and npm install it works as it should be.

If anyone is encountering the EEXIST error on MacOS, please try a node version of 10.16.0 or greater. There is a known issue with copying files on earlier versions of node for MacOS.

I’m no expert, but I’d suggest, if you are still having this problem with the latest Angular CLI, completely deleting node_modules, and re-installing. Then, if you are still having the problem, report this as a new related issue (with a link to this one), since this issue is closed, and was fixed, at least for the case reported originally.

@jjz4689 my assumption is that some data in the npm cache was causing the issue. Worked for me πŸ™ƒ

@pagimaxx I had the same issue, but it was resolved after running npm ci. Give that a shot

Same problem with:

Can someone help me on this, I am getting this error β€˜EEXIST: file already exists, mkdir’ when I execute ng build --prod with --output-path flag specified.

I have:

  • angular/cli version 7.3.8
  • angular-devkit/build-angular 0.13.9
  • node 10.15.3 (npm 6.4.1)

@clydin Thank you very much for pointing me in the right direction, indeed my problems went away by updating. Also my concern about the file mode setting is obsolete with commit 0cb10d6029f59842b2f6e0a791d78b43ea1a7460.