Angular-cli: npm start lint, cannot parse the template

Created on 21 Oct 2016  路  14Comments  路  Source: angular/angular-cli

Hello, after upgrade to newest version of angular-cli (from beta 17) and runing command npm start lint I have error:

Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at InputMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at InputMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at InputMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at InputMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at InputMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at OutputMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at OutputMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at OutputMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at OutputMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at OutputMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at ClassMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at ClassMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at ClassMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at ClassMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at ClassMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at ClassMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at ClassMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at ClassMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at ClassMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at ClassMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at Ng2Walker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at Ng2Walker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at Ng2Walker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at InputMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at InputMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at InputMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at InputMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at InputMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at OutputMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at OutputMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at OutputMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at OutputMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at OutputMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at ClassMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at ClassMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at ClassMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at ClassMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at ClassMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at ClassMetadataWalker.Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at ClassMetadataWalker.Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at ClassMetadataWalker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at ClassMetadataWalker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at ClassMetadataWalker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14) Cannot parse the template TypeError: Cannot read property 'TemplateParser' of undefined at Object.exports.parseTemplate (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\templateParser.js:7:27) at Ng2Walker.visitClassDecorator (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:123:70) at Array.forEach (native) at Ng2Walker.visitClassDeclaration (C:\htdocs\GP.Hub\node_modules\codelyzer\angular\ng2Walker.js:73:40) at Ng2Walker.SyntaxWalker.visitNode (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:264:22) at C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:63 at visitEachNode (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8251:30) at Object.forEachChild (C:\htdocs\GP.Hub\node_modules\typescript\lib\typescript.js:8411:24) at Ng2Walker.SyntaxWalker.walkChildren (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:459:12) at Ng2Walker.SyntaxWalker.visitSourceFile (C:\htdocs\GP.Hub\node_modules\tslint\lib\language\walker\syntaxWalker.js:190:14)

Most helpful comment

Same here. Downgrading codelyzer to ~0.0.26 (and removing the new tslint rules) fixes the problem for me.

All 14 comments

Same here. Downgrading codelyzer to ~0.0.26 (and removing the new tslint rules) fixes the problem for me.

Same here. Downgrading codelyzer fixed the issue (thx @binarious :))

Yea, but downgrading codelyzer is breaking unit tests(at least on my side).

after runing tests it shows

Could not find implementations for the following rules specified in the configuration:
templates-use-public
              invoke-injectable

so if you're downgrading codelyzer then remove

    "templates-use-public": true,
    "invoke-injectable": true

from tslint.json

Same problem also for me. Thanks @binarious !

Same problem, thanks for the suggestion @binarious

I assume that you mean npm run lint or ng lint and not npm start lint which will try to run ng serve "lint"?

It's working for me with "codelyzer": "1.0.0-beta.2" and "lint": "tslint -c tslint.json 'src/app/**/*.ts' 'src/environments/*.ts' 'src/*.ts'".

Oh, it appears to be a problem with Angular 2.1.1. After I upgraded to that from 2.1.0, I started to see this issue.

This issue is fixed in https://github.com/mgechev/codelyzer/pull/124 which hasn't been merged or released yet.

Do you know when the bugfix will be released ?

Same here

@nicolae536 and @ajmebc Fixed in codelyzer 1.0.0-beta.3. I've verified it personally.

@morriq This issue should be resolved once https://github.com/angular/angular-cli/issues/2812 is merged and angular-cli beta.19 is released. Workaround for now is to use beta.3 of codelyzer.

I just installed angular-cli beta.19 and re-ran ng init. Turns out it wants version 1.0.0-beta.1 of codelyzer, didn't show it as a diff to upgrade to beta.3

I assume this is not in beta.19-3 of angular-cli @filipesilva ?

@JohannesRudolph it's not in beta.19-3, it was merged afterwards.

Upgrading to codelyzer 1.0.0-beta.3 does the trick for me. I'm using angular-cli 1.0.0-beta.19-3

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._

Was this page helpful?
0 / 5 - 0 ratings