Skip to content

Running build with --prod twice gives EEXIST error. #15494

Closed
@bennadel

Description

@bennadel

🐞 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 am mostly sure this is a regression. When I was on "8 next", I could run build more than once (not sure which version the CLI was at the time). But, on "9 next", or just the current ng new, it seems to break.

Description

I just did an ng new command. Then, going into the project, if I run this twice in a row:

npm run build -- --prod

... it will work the first time. But, upon the second execution, I get the EEXIST error:

> ng build "--prod"

chunk {0} runtime-es2015.24b02acc1f369d9b9f37.js (runtime) 2.83 kB [entry] [rendered]
chunk {1} main-es2015.c1ca90f926552c3d2864.js (main) 369 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]
Date: 2019-08-31T10:44:47.301Z - Hash: ac5960e989c86bda1855 - Time: 16200ms
Generating ES5 bundles for differential loading...
An unhandled exception occurred: EEXIST: file already exists, copyfile '/Users/ben/Sites/bennadel.com/projects/breadboarding-poc-cli/node_modules/.cache/angular-build-dl/content-v2/sha512/36/86/afb82f76da09848c154ccb79a5213dc67698763412e526216fbce17a94bd0b1762da3627677b3ee97a05cdc837739fdc4dbdc08b13fbd50cbb0fb9a0b512' -> '/Users/ben/Sites/bennadel.com/projects/breadboarding-poc-cli/dist/breadboarding-poc-cli/runtime-es2015.24b02acc1f369d9b9f37.js'
See "/private/var/folders/49/h6_w8znd50vgwbbbwdxqsmlh0000gn/T/ng-c1s0RZ/angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] build: `ng build "--prod"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ben/.npm/_logs/2019-08-31T10_44_47_385Z-debug.log

Note that if I remove the --prod, I can run multiple builds without issue. Also note that if I delete the node_modules/.cache folder, I can re-run the prod build.

🔬 Minimal Reproduction

  1. Create a new project with the CLI, ng new test
  2. Go into test, cd test
  3. Run build with prod flag, npm run build -- --prod
  4. Run build with prod flag npm run build -- --prod

The first build will work, the second build will break.

🔥 Exception or Error


ip-192-168-0-18:breadboarding-poc-cli ben$ npm run build -- --prod

> [email protected] build /Users/ben/Sites/bennadel.com/projects/breadboarding-poc-cli
> ng build "--prod"


chunk {0} runtime-es2015.24b02acc1f369d9b9f37.js (runtime) 2.83 kB [entry] [rendered]
chunk {1} main-es2015.c1ca90f926552c3d2864.js (main) 369 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]
Date: 2019-08-31T10:44:47.301Z - Hash: ac5960e989c86bda1855 - Time: 16200ms
Generating ES5 bundles for differential loading...
An unhandled exception occurred: EEXIST: file already exists, copyfile '/Users/ben/Sites/bennadel.com/projects/breadboarding-poc-cli/node_modules/.cache/angular-build-dl/content-v2/sha512/36/86/afb82f76da09848c154ccb79a5213dc67698763412e526216fbce17a94bd0b1762da3627677b3ee97a05cdc837739fdc4dbdc08b13fbd50cbb0fb9a0b512' -> '/Users/ben/Sites/bennadel.com/projects/breadboarding-poc-cli/dist/breadboarding-poc-cli/runtime-es2015.24b02acc1f369d9b9f37.js'
See "/private/var/folders/49/h6_w8znd50vgwbbbwdxqsmlh0000gn/T/ng-c1s0RZ/angular-errors.log" for further details.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] build: `ng build "--prod"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ben/.npm/_logs/2019-08-31T10_44_47_385Z-debug.log

🌍 Your Environment


Angular CLI: 8.3.2
Node: 10.11.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?

No, I don't think so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions