node.jsangularnpmangular2-material

Angular 2 - Cannot read property 'AssetUrl' of undefined


I am new at angular2 and material-design. I am trying to use them togeather.

I cloned this material2-app, which is application code based on angular2 and material2 and run npm install.

When I run this command npm start to start a server. I got this error. Any Leads ?

Error-from-terminal

> m2-app@0.0.0 start /home/adil/Code/AngularJS.2/a-simple-app/material2-app
> ng serve

Cannot read property 'AssetUrl' of undefined
TypeError: Cannot read property 'AssetUrl' of undefined
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@angular/compiler-cli/src/private_import_compiler.js:10:51)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@angular/compiler-cli/src/reflector_host.js:13:33)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@angular/compiler-cli/src/path_mapped_reflector_host.js:16:24)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@angular/compiler-cli/src/codegen.js:16:36)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@angular/compiler-cli/index.js:12:17)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@ngtools/webpack/src/plugin.js:6:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/@ngtools/webpack/src/index.js:6:10)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/models/webpack-build-typescript.js:5:17)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/models/webpack-config.js:2:34)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/tasks/build-webpack.js:6:24)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/commands/build.js:3:23)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Class.module.exports.includedCommands (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/addon/index.js:21:16)
at /home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/models/project.js:392:61
at Array.forEach (native)
at Project.addonCommands (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/models/project.js:391:15)
at Project.eachAddonCommand (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/models/project.js:426:30)
at module.exports (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
at CLI.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/cli/cli.js:34:26)
at tryCatch (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:538:12)
at invokeCallback (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:553:13)
at publish (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:521:7)
at flush (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:2373:5)
at nextTickCallbackWith0Args (node.js:419:9)
at process._tickCallback (node.js:348:13)

npm ERR! Linux 4.4.0-45-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! m2-app@0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the m2-app@0.0.0 start script 'ng serve'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the m2-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ng serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs m2-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls m2-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/adil/Code/AngularJS.2/a-simple-app/material2-   app/npm-debug.log

Solution

  • I faced similar issue. It seems to problem with new compiler-cli of Angular. I resolved it by adding following in devDependencies in package.json

    "@angular/compiler-cli": "^2.0.0"
    

    After doing npm install again error was gone.