Topic: Toolips ng build –prod error

jimsgroup pro asked 7 years ago


when I was trying to build production of my project we got this error:

in Error: TypeError: Cannot read property 'kind' of undefined
at nodeCanBeDecorated (C:\XXX\Websitenode_modulestypescriptlibtypescript.js:7805:35)

Then I dig into the sourcecode. I found it was caused by tooptips.directive.ts line 18.

If I remove "@OnChange".  building will work.

So far we didn't use this directive and I don't know how much effect will be if i remove this code.

Would you mind give me some suggestion on this?

Thanks.

my environment is:

Angular CLI: 1.5.5
Node: 6.11.3
OS: win32 x64
Angular: 5.0.5
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

@angular/cli: 1.5.5
@angular/language-service: 4.4.6
@angular-devkit/build-optimizer: 0.0.34
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.5
@schematics/angular: 0.1.9
typescript: 2.4.2
webpack: 3.8.1


jimsgroup pro commented 7 years ago

Any ideas?

Damian Gemza staff answered 7 years ago


Hey Guys,

I've checked this case, and found a fix for that. It's problem with Typescript. I think, that it will be fixed in next TypeScript releases, but for now you can try to use solution of user 'gmavritsakis' added on GitHub: https://github.com/angular/angular-cli/issues/8434 .

In file 'typescript.js' located in: node_modules/typescript/lib

Replace all the function
function nodeCanBeDecorated(node)
with the following code:

function nodeCanBeDecorated(node) {
       switch (node.kind) {
           case 229 /* ClassDeclaration */:
               // classes are valid targets
               return true;
           case 149 /* PropertyDeclaration */:
               // property declarations are valid if their parent is a class declaration.
   			// return node.parent.kind === 229 /* ClassDeclaration */;
   			return (node.parent && node.parent.kind === 229) || (node.original && node.original.parent && node.original.parent.kind === 229);
           case 153 /* GetAccessor */:
           case 154 /* SetAccessor */:
           case 151 /* MethodDeclaration */:
               // if this method has a body and its parent is a class declaration, this is a valid target.
               return node.body !== undefined &&
   				// && node.parent.kind === 229 /* ClassDeclaration */;
   				(node.parent && node.parent.kind === 229) || (node.original && node.original.parent && node.original.parent.kind === 229);
           case 146 /* Parameter */:
               // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
               // return node.parent.body !== undefined
               //     && (node.parent.kind === 152 /* Constructor */
               //         || node.parent.kind === 151 /* MethodDeclaration */
               //         || node.parent.kind === 154 /* SetAccessor */)
   			//     && node.parent.parent.kind === 229 /* ClassDeclaration */;
   			
   			var parent = node.parent || (node.original && node.original.parent);
   			return parent && parent.body !== undefined &&
                     (parent.kind === 152
                        || parent.kind === 151
                        || parent.kind === 154) && parent.parent.kind === 229;
       }
       return false;
   }

Vitor Pavanelli free commented 6 years ago

It works for me! thank you

nthieu13 pro answered 7 years ago


I got this issue too but with latest angular stack on fresh new project. I doubt that this issue comes from @angular/cli because when I disabled  --aot and --build-optimizer, there is no error . Some code in MDBBootstrapModules cannot build in prod mode with --aot and --build-optimizer which is enabled by default in new @angular/cli. Please consider fixing your code because these build options is crucial. My environment: Angular CLI: 1.6.0 Node: 8.8.1 OS: linux x64 Angular: 5.1.0 ERROR in : TypeError: Cannot read property 'kind' of undefined at nodeCanBeDecorated (/home/hnguyen/webapp/node_modules/typescript/lib/typescript.js:7805:36)  

Dawid Adach pro commented 7 years ago

Dear nthieu, as mentioned before (as we as our package.json) MDB PRO is tested and compatible with Angular 1.5 , the newer versions are not fully tested yet therefore some issues may occur. We are working on new release which will be compatible with new newer versions of CLI.

Dawid Adach pro answered 7 years ago


Dear jimsgroup ,

There are quite a few known issues regarding the newest Angular and CLI, could you please try to downgrade your CLI to 1.5.0 ? We are continuously working with Angular team on that and adjusting our library to work correctly with the newest Angular however quite often we have to wait until Angular team fix something on their side.

For now, please either downgrade or comment following directive since you didn't use it, I hope that by the time we release next package (probably next week) this issue will be solved either on our or their side (depending on where the root cause actually is)


thefabio free commented 7 years ago

Same issue here... when using CLI 1.6.0 or 1.5.5 or 1.5.2 it has the same error, but it works with CLI 1.5.0! Hopefully you guys have it adjusted so it works with 1.6!

Dawid Adach pro commented 7 years ago

Dear thefabio, yes we are working on new release which will be compatible with new CLI as well.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Closed

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags