Angular library build error: TypeError: Cannot read property 'type' of null
In Angular v6, when attempting to build my library I am running into an extremely non-descriptive BUILD ERROR Cannot read property 'type' of null
BUILD ERROR
Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15378:27
at Array.forEach (<anonymous>)
at removeSummaryDuplicates (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15377:11)
at TemplateParser.tryParseHtml (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14806:34)
at TemplateParser.tryParse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14799:21)
at TemplateParser.parse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14780:27)
at AotCompiler._parseTemplate (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20483:43)
at AotCompiler._createTypeCheckBlock (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20250:23)
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20220:27
at Array.forEach (<anonymous>)
Having already solved this problem, I'm making this post to help anyone else running into this issue.
angular angular-aot
add a comment |
In Angular v6, when attempting to build my library I am running into an extremely non-descriptive BUILD ERROR Cannot read property 'type' of null
BUILD ERROR
Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15378:27
at Array.forEach (<anonymous>)
at removeSummaryDuplicates (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15377:11)
at TemplateParser.tryParseHtml (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14806:34)
at TemplateParser.tryParse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14799:21)
at TemplateParser.parse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14780:27)
at AotCompiler._parseTemplate (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20483:43)
at AotCompiler._createTypeCheckBlock (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20250:23)
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20220:27
at Array.forEach (<anonymous>)
Having already solved this problem, I'm making this post to help anyone else running into this issue.
angular angular-aot
add a comment |
In Angular v6, when attempting to build my library I am running into an extremely non-descriptive BUILD ERROR Cannot read property 'type' of null
BUILD ERROR
Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15378:27
at Array.forEach (<anonymous>)
at removeSummaryDuplicates (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15377:11)
at TemplateParser.tryParseHtml (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14806:34)
at TemplateParser.tryParse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14799:21)
at TemplateParser.parse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14780:27)
at AotCompiler._parseTemplate (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20483:43)
at AotCompiler._createTypeCheckBlock (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20250:23)
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20220:27
at Array.forEach (<anonymous>)
Having already solved this problem, I'm making this post to help anyone else running into this issue.
angular angular-aot
In Angular v6, when attempting to build my library I am running into an extremely non-descriptive BUILD ERROR Cannot read property 'type' of null
BUILD ERROR
Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15378:27
at Array.forEach (<anonymous>)
at removeSummaryDuplicates (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:15377:11)
at TemplateParser.tryParseHtml (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14806:34)
at TemplateParser.tryParse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14799:21)
at TemplateParser.parse (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:14780:27)
at AotCompiler._parseTemplate (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20483:43)
at AotCompiler._createTypeCheckBlock (/Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20250:23)
at /Users/John/apps/tests/service-work/node_modules/@angular/compiler/bundles/compiler.umd.js:20220:27
at Array.forEach (<anonymous>)
Having already solved this problem, I'm making this post to help anyone else running into this issue.
angular angular-aot
angular angular-aot
asked May 26 '18 at 2:40
JohnJohn
2,7681229
2,7681229
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Update
It seems like my diagnosis of this issue was incorrect (it's been so long now I can't remember exactly show I fixed it). Check out this issue in the Angular repo for what sounds like the correct diagnosis,
Original answer:
So after a LOT of debugging, I figured it out:
My custom library, let call it library A, imports another custom library, library B, into library A's NgModule
. Library B exports several components and modules from it's main NgModule
. The problem was that, while library B exported the components and modules from it's NgModule
, I failed to also export those components and modules via javascript/typescript. The solution was to make sure to export any components / modules via typescript that I exported in the NgModule
.
Example problem code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Solution code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
export LibraryBComponent // <-- addition
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file viapublic_api.ts
barrel.
– George Knap
Aug 24 '18 at 9:10
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that mypolyfills.ts
file was missing a required polyfill (I think theReflect
api, but I'm not sure).
– John
Aug 24 '18 at 10:14
add a comment |
My issue was on <projectRoot>/tsconfig.json
(you can check it on #24143(comment))
Basically I had to remove the paths from tsconfig.json
like:
"library-b": [
"dist/library-b"
],
"library-b/*": [
"dist/library-b/*"
]
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50538843%2fangular-library-build-error-typeerror-cannot-read-property-type-of-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update
It seems like my diagnosis of this issue was incorrect (it's been so long now I can't remember exactly show I fixed it). Check out this issue in the Angular repo for what sounds like the correct diagnosis,
Original answer:
So after a LOT of debugging, I figured it out:
My custom library, let call it library A, imports another custom library, library B, into library A's NgModule
. Library B exports several components and modules from it's main NgModule
. The problem was that, while library B exported the components and modules from it's NgModule
, I failed to also export those components and modules via javascript/typescript. The solution was to make sure to export any components / modules via typescript that I exported in the NgModule
.
Example problem code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Solution code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
export LibraryBComponent // <-- addition
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file viapublic_api.ts
barrel.
– George Knap
Aug 24 '18 at 9:10
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that mypolyfills.ts
file was missing a required polyfill (I think theReflect
api, but I'm not sure).
– John
Aug 24 '18 at 10:14
add a comment |
Update
It seems like my diagnosis of this issue was incorrect (it's been so long now I can't remember exactly show I fixed it). Check out this issue in the Angular repo for what sounds like the correct diagnosis,
Original answer:
So after a LOT of debugging, I figured it out:
My custom library, let call it library A, imports another custom library, library B, into library A's NgModule
. Library B exports several components and modules from it's main NgModule
. The problem was that, while library B exported the components and modules from it's NgModule
, I failed to also export those components and modules via javascript/typescript. The solution was to make sure to export any components / modules via typescript that I exported in the NgModule
.
Example problem code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Solution code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
export LibraryBComponent // <-- addition
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file viapublic_api.ts
barrel.
– George Knap
Aug 24 '18 at 9:10
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that mypolyfills.ts
file was missing a required polyfill (I think theReflect
api, but I'm not sure).
– John
Aug 24 '18 at 10:14
add a comment |
Update
It seems like my diagnosis of this issue was incorrect (it's been so long now I can't remember exactly show I fixed it). Check out this issue in the Angular repo for what sounds like the correct diagnosis,
Original answer:
So after a LOT of debugging, I figured it out:
My custom library, let call it library A, imports another custom library, library B, into library A's NgModule
. Library B exports several components and modules from it's main NgModule
. The problem was that, while library B exported the components and modules from it's NgModule
, I failed to also export those components and modules via javascript/typescript. The solution was to make sure to export any components / modules via typescript that I exported in the NgModule
.
Example problem code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Solution code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
export LibraryBComponent // <-- addition
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Update
It seems like my diagnosis of this issue was incorrect (it's been so long now I can't remember exactly show I fixed it). Check out this issue in the Angular repo for what sounds like the correct diagnosis,
Original answer:
So after a LOT of debugging, I figured it out:
My custom library, let call it library A, imports another custom library, library B, into library A's NgModule
. Library B exports several components and modules from it's main NgModule
. The problem was that, while library B exported the components and modules from it's NgModule
, I failed to also export those components and modules via javascript/typescript. The solution was to make sure to export any components / modules via typescript that I exported in the NgModule
.
Example problem code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
Solution code
import NgModule from '@angular/core';
import CommonModule from '@angular/common';
import LibraryBComponent from './library-b.component';
export LibraryBComponent // <-- addition
@NgModule(
imports: [CommonModule],
declarations: [LibraryBComponent],
exports: [LibraryBComponent],
)
export class LibraryBModule
edited Sep 19 '18 at 11:15
answered May 26 '18 at 2:40
JohnJohn
2,7681229
2,7681229
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file viapublic_api.ts
barrel.
– George Knap
Aug 24 '18 at 9:10
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that mypolyfills.ts
file was missing a required polyfill (I think theReflect
api, but I'm not sure).
– John
Aug 24 '18 at 10:14
add a comment |
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file viapublic_api.ts
barrel.
– George Knap
Aug 24 '18 at 9:10
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that mypolyfills.ts
file was missing a required polyfill (I think theReflect
api, but I'm not sure).
– John
Aug 24 '18 at 10:14
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file via
public_api.ts
barrel.– George Knap
Aug 24 '18 at 9:10
Unfortunatelly I'm exactly in the same situation and this solution does not work for me. In a way it makes sense because the component I'm exporting is already exported from it's own file via
public_api.ts
barrel.– George Knap
Aug 24 '18 at 9:10
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap it's been long enough that I don't remember too many details of this problem, but I think I ended up fixing things by creating a new, working, blank angular app, porting over my modules and code piece by piece, and incrementally rebuilding the app along the way searching for build errors. That way I was able to figure out exactly what code broke things. It was an extremely time consuming debugging process.
– John
Aug 24 '18 at 10:09
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that my
polyfills.ts
file was missing a required polyfill (I think the Reflect
api, but I'm not sure).– John
Aug 24 '18 at 10:14
@GeorgeKnap Also, I may be remembering this incorrectly, but I think I ran into this problem while upgrading from angular v5 to v6, and I think one of the problems was that my
polyfills.ts
file was missing a required polyfill (I think the Reflect
api, but I'm not sure).– John
Aug 24 '18 at 10:14
add a comment |
My issue was on <projectRoot>/tsconfig.json
(you can check it on #24143(comment))
Basically I had to remove the paths from tsconfig.json
like:
"library-b": [
"dist/library-b"
],
"library-b/*": [
"dist/library-b/*"
]
add a comment |
My issue was on <projectRoot>/tsconfig.json
(you can check it on #24143(comment))
Basically I had to remove the paths from tsconfig.json
like:
"library-b": [
"dist/library-b"
],
"library-b/*": [
"dist/library-b/*"
]
add a comment |
My issue was on <projectRoot>/tsconfig.json
(you can check it on #24143(comment))
Basically I had to remove the paths from tsconfig.json
like:
"library-b": [
"dist/library-b"
],
"library-b/*": [
"dist/library-b/*"
]
My issue was on <projectRoot>/tsconfig.json
(you can check it on #24143(comment))
Basically I had to remove the paths from tsconfig.json
like:
"library-b": [
"dist/library-b"
],
"library-b/*": [
"dist/library-b/*"
]
answered Nov 13 '18 at 10:09
Fabio PicheliFabio Picheli
616520
616520
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50538843%2fangular-library-build-error-typeerror-cannot-read-property-type-of-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown