TypeError: visitor.visitUnaryOperatorExpr is not a function

Viewed 513

I'm building an Angular app based on a template that was purchased for the task, and am working with another person. At the start of the project I was able to build for prod with ng build --prod. Yesterday I attempted to build and was presented with the error TypeError: visitor.visitUnaryOperatorExpr is not a function (full error below). Is there any way to get a full stack trace or to solve this problem? I've tried the following:

  1. build with ng build --prod --source-map=true
  2. build with ng build --configuration=production --source-map=true
  3. updating all node and angular packages through npm

Below is the stacktrace produced:

Error: TypeError: visitor.visitUnaryOperatorExpr is not a function
    at UnaryOperatorExpr.visitExpression (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler\bundles\compiler.umd.js:1976:28)
    at NodeEmitterVisitor.visitConditionalExpr (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:468:132)
    at ConditionalExpr.visitExpression (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler\bundles\compiler.umd.js:1865:28)    at NodeEmitterVisitor.visitDeclareVarStmt (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:313:65)
    at DeclareVarStmt.visitStatement (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler\bundles\compiler.umd.js:2185:28)  
    at M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:573:105
    at Array.map (<anonymous>)
    at NodeEmitterVisitor._visitStatementsPrefix (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:573:71)
    at NodeEmitterVisitor._visitStatements (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:569:25)
    at NodeEmitterVisitor.visitFunctionExpr (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:486:40)
    at FunctionExpr.visitExpression (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler\bundles\compiler.umd.js:1951:28)   
    at M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:451:162
    at Array.map (<anonymous>)
    at NodeEmitterVisitor.visitInvokeFunctionExpr (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:451:130)
    at InvokeFunctionExpr.visitExpression (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler\bundles\compiler.umd.js:1655:28)
    at NodeEmitterVisitor.visitReturnStmt (M:\User\Documents\GitHub\Website-2.0\node_modules\@angular\compiler-cli\src\transformers\node_emitter.js:336:78)```
1 Answers

I can only be guessing what version of angular you're using, and what dependencies you have in packages.json.

Anyway, I've experienced the same problem and it appeared that I have an older version of Angular Compiler CLI. After I run npm i @angular/compiler-cli@latest error is gone.

Related