Angular Library Build fails with NON-descriptive error [object Object]
See original GitHub issueCurrent Behavior
Setup:
- EDIT it turned out the error can be triggered by generating a lib and changing its
name
in the inlinepackage.json
from@org/a/b/c
to@org/a-b-c
without adjusting the paths intsconfig.base.json
- 3 libs with no implementation
ui -> feature -> shell
- all libs created created using
--buildable
flag - shell consumed by an example application
- build triggered using
nx build
The build fails for the feature
lib with a very NON-descriptive error [object Object]
Expected Behavior
Build works or at least fails with a descriptive error
Workaround
Adding console.error()
to the following place, based on my understanding the NX catches all the re-thrown errors on some higher level and tries to stringify them which leads to [object Object]
so maybe there can be some more robust logic to detect if error is an object of different sorts and come up with more destriptive error in that case?
Failure Logs
------------------------------------------------------------------------------
Building entry point '@org/some-lib'
------------------------------------------------------------------------------
[object Object] <--- this is really not helpful
With workaround
FatalDiagnosticError {
code: 3004,
node: <ref *1> SourceFileObject {
pos: 0,
end: 0,
flags: 0,
modifierFlagsCache: 0,
transformFlags: 0,
parent: undefined,
kind: 303,
statements: [ pos: 0, end: 0, hasTrailingComma: false, transformFlags: 0 ],
endOfFileToken: TokenObject {
pos: 0,
end: 0,
flags: 0,
modifierFlagsCache: 0,
transformFlags: 0,
parent: [Circular *1],
kind: 1
},
fileName: '/home/tomastrajan/projects/mobi/rwc-b2e-workspace/libs/b2e/public/ui/button/src/lib/button/button.component.ngtypecheck.ts',
text: '',
languageVersion: 99,
languageVariant: 0,
scriptKind: 3,
isDeclarationFile: false,
hasNoDefaultLib: false,
externalModuleIndicator: undefined,
bindDiagnostics: [],
bindSuggestionDiagnostics: undefined,
pragmas: Map(0) {},
checkJsDirective: undefined,
referencedFiles: [],
typeReferenceDirectives: [],
libReferenceDirectives: [],
amdDependencies: [],
commentDirectives: undefined,
nodeCount: 2,
identifierCount: 0,
identifiers: Map(0) {},
parseDiagnostics: []
},
message: {
category: 3,
code: 0,
messageText: 'Unable to import symbol ButtonComponent.',
next: [ [Object] ]
},
relatedInformation: [
{
category: 3,
code: 0,
file: [SourceFileObject],
start: 44,
length: 162,
messageText: 'The symbol is declared here.'
}
],
_isFatalDiagnosticError: true
}
[object Object]
Environment
> NX Report complete - copy this into the issue template
Node : 14.16.0
OS : linux x64
npm : 6.14.11
nx : 13.8.3
@nrwl/angular : 13.8.3
@nrwl/cli : 13.8.3
@nrwl/cypress : 13.8.3
@nrwl/detox : undefined
@nrwl/devkit : 13.8.3
@nrwl/eslint-plugin-nx : 13.8.3
@nrwl/express : undefined
@nrwl/jest : 13.8.3
@nrwl/js : 13.8.3
@nrwl/linter : 13.8.3
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.8.3
@nrwl/tao : 13.8.3
@nrwl/web : 13.8.3
@nrwl/workspace : 13.8.3
typescript : 4.5.5
rxjs : 7.4.0
---------------------------------------
Community plugins:
@angular/animations: 13.2.2
@angular/common: 13.2.2
@angular/compiler: 13.2.2
@angular/core: 13.2.2
@angular/forms: 13.2.2
@angular/platform-browser: 13.2.2
@angular/platform-browser-dynamic: 13.2.2
@angular/router: 13.2.2
@angular-devkit/build-angular: 13.2.3
@angular/cli: 13.2.3
@angular/compiler-cli: 13.2.2
@angular/language-service: 13.2.2
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Angular 12 Library Builds Fails with error [object Object]
After days of debugging I finally found the reason. A component in the library was importing a file from another library using its...
Read more >Overview of Angular libraries
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces ......
Read more >Unity 2022.1.0b7
Android: Builds will fail early and with a human readable error message, when Unity project is located in path with Non ASCII characters....
Read more >What's new in Unity 2022.1.0 Alpha 15 - Unity
WebGL: Build fails to launch due to Runtime errors (1371445) ... Editor: Improved performance of picking large objects in Scene View.
Read more >ATP 3-09.30 Observed Fires - Army Publishing Directorate
Correction of Errors . ... High-Angle Fire . ... An entity or object that performs a function for the adversary considered for possible....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same error and your workaround helped me diagnose the issue, thanks for that!
I would add that as far as my workspace was concerned, running
nx reset
(clearing Nx caches) fixed the issue and allowed me to build the library.@tomastrajan it does make sense. I had a look again at the error object you shared above and I can see why
[object Object]
is being printed. We print theerror.message
as is because that property is expected to be astring
and not a complex object. In the error above is a complex object which is wrong and it turns out that theFatalDiagnosticError
shouldn’t be thrown and instead be converted to ats.Diagnostics
, this is an issue in the@angular/compiler-cli
that’s being reported here.