x)- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
First time creating library myself, but I have never seen this bug in other libraries.
Each run of my library (ng build hal-components) (my library) is missing random files in the dist/hal-components/lib folder. A few runs gives me all files, but most (ca 90%) is missing several files. The files missing changes on each run.
Restarting the computer temporarily solves the problem, but it returns after a few hours to one days of use without a restart
Still get the bug if I stop the ng serve command on the consuming project. I get the bug both with, and without the watch flag.
This bug is really annoying as I need to manually check if all files are present before publishing to NPM.
Library is still tiny so I can link to it:
https://github.com/hafslundnett/hal-components/tree/build-bug
Only getting the bug on Windows (also tested on Mac, but did not get the bug).
Bug is periodic, but what I do is:
yarnng build hal-componentsdist/hal-components/lib for missing components from the libraryThere is no error, just random missing files.
Angular CLI: 8.3.12
Node: 10.16.0
OS: win32 x64
Angular: 8.1.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.801.3
@angular-devkit/build-angular 0.801.3
@angular-devkit/build-ng-packagr 0.801.3
@angular-devkit/build-optimizer 0.801.3
@angular-devkit/build-webpack 0.801.3
@angular-devkit/core 8.3.12
@angular-devkit/schematics 8.3.12
@angular/cdk 8.2.3
@angular/cli 8.3.12
@angular/material 8.2.3
@ngtools/webpack 8.1.3
@schematics/angular 8.3.12
@schematics/update 0.803.12
ng-packagr 5.7.0
rxjs 6.4.0
typescript 3.4.5
webpack 4.35.2
Anything else relevant?
Running the latest version of Windows 10 Enterprise.
I understand this will be hard to solve, so I appreciate any workaround as a solution if anyone has a suggestion.
@JGH153, I tried to take a look at this add did several runs with the reproduction you provided by I always managed to get 12 component files.
c:\git\cli-repos\hal-components (trunk -> origin)
位 ng build hal-components && ls -R | grep '.*[.]component.js' | wc -l
Building Angular Package
------------------------------------------------------------------------------
Building entry point '@hafslundnett/hal-components'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Built @hafslundnett/hal-components
------------------------------------------------------------------------------
Built Angular Package!
- from: c:\git\cli-repos\hal-components\projects\hal-components
- to: c:\git\cli-repos\hal-components\dist\hal-components
------------------------------------------------------------------------------
12
I am too running on a windows machine.
What I am seeing strange is that if one of the files is missing the build will fail because to generate the FESM 2015 and FESM 5 bundles all files needs to be on disk.
I am thinking that you might be having a background process that is deleting the files after the build. Maybe a too strict anti-virus or something along this source.
Ok so the missing files needs to be present during the build step for it to work. That's a really helpful clue. Never had my anti-virus delete files like that, but I鈥檒l give it a try. And I鈥檒l also terminate any other processes that potentially can delete the files and see if the problems persists.
I have the same problem sometimes. In my case, most of the time it's some random files under lib (the definition files) that are missing, bundles/esm/fesm seem to be ok. I also have the feeling that the problem occurs more often with files nested in folders.
Example:
lib
checkbox
checkbox.component.d.ts // <- this file is present more often ...
checkbox-with-label // <- ... than this folder and its sub-files
checkbox-with-label.component.d.ts
This problem also occurs when doing the build in watch mode. The files that are missing in watch mode will not get built as long as you don't touch them manually (do some changes to the file), so for me it seems that the cli just misses them out until someone points them out to it again.
@dummdidumm can you please elaborate a bit more on the below statement.
The files that are missing in watch mode will not get built as long as you don't touch them manually (do some changes to the file), so for me it seems that the cli just misses them out until someone points them out to it again.
@dummdidumm can you please elaborate a bit more on the below statement.
The files that are missing in watch mode will not get built as long as you don't touch them manually (do some changes to the file), so for me it seems that the cli just misses them out until someone points them out to it again.
When a file is not part of the output under lib in watch mode, this file will not appear in the output as long as you don't touch the file. So if I for example change code or make a comment in that file and then save that file, only then will that file appear in the output, not sooner.
The situation of not having all files under lib occurs more often if i have my main app running (ng serve), which gets some files from the lib which is then (re)built. Also I feel that when I have VS Code open for some time the chance increases of that happening. So maybe it's processes watching/touching/locking files (VS Code, Angular Language Service, ng serve, ng build --project=my-lib --watch) that conflict with each other?
I also sometimes get "operation not permitted"-errors like this when trying to build the library, maybe this is related:
BUILD ERROR
EPERM: operation not permitted, unlink 'C:\repos\rotec-components\dist\rotec-components\lib\action-menu'
Error: EPERM: operation not permitted, unlink 'C:\repos\rotec-components\dist\rotec-components\lib\action-menu'
EPERM: operation not permitted, unlink 'C:\repos\rotec-components\dist\rotec-components\lib\action-menu'
Error: EPERM: operation not permitted, unlink 'C:\repos\rotec-components\dist\rotec-components\lib\action-menu'
npm error log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'watch' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ]
5 info lifecycle [email protected]~prewatch: [email protected]
6 info lifecycle [email protected]~watch: [email protected]
7 verbose lifecycle [email protected]~watch: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~watch: PATH: <- took out because of privacy reasons ->
9 verbose lifecycle [email protected]~watch: CWD: C:\repos\rotec-components
10 silly lifecycle [email protected]~watch: Args: [ '/d /s /c', 'ng build --project=rotec-components --watch' ]
11 silly lifecycle [email protected]~watch: Returned: code: 1 signal: null
12 info lifecycle [email protected]~watch: Failed to exec watch script
13 verbose stack Error: [email protected] watch: `ng build --project=rotec-components --watch`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\repos\rotec-components
16 verbose Windows_NT 10.0.17763
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
18 verbose node v10.15.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] watch: `ng build --project=rotec-components --watch`
22 error Exit status 1
23 error Failed at the [email protected] watch script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Found the cause of the bug. I get missing files 100% of the time when I use the Angular language service plugin for vscode AND have one or more files in the library open during a build of the library (for example app-shell). Disabling the plugin gives all files always after more than 20 runs. Should I file this issue with vscode-ng-language-service?
Seems to be a well known bug: https://github.com/ng-packagr/ng-packagr/issues/837#issuecomment-428447353
Adding "exclude": ["dist"] to tsconfig and running the library build/watch from a terminal with administrative privileges seems like it solved the problem with missing files and the language service
If part of the problem (if not all) is solved by adding dist to exclude, maybe the angular-cli could add this to the tsconfig.json (lib/app/root) by default?
The workaround was more stable, but broke down as well in the end. Had to disable the plugin
We definitely should exclude dist
This should have been fixed with the latest v0.900.0 extension, which is already published.
The env flag TSC_NONPOLLING_WATCHER is now enforced, and it should not lock up the fs anymore.
This issue has the same underlying root cause as https://github.com/angular/vscode-ng-language-service/issues/224, which is now closed.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._