Angular 2 - 无法读取未定义的 属性 'AssetUrl'
Angular 2 - Cannot read property 'AssetUrl' of undefined
我是 angular2
和 material-design
的新人。我正在尝试将它们一起使用。
我cloned
这个material2-app,这是基于angular2
和material2
和运行npm install
的应用程序代码。
当我运行这个命令npm start
启动一个服务器。我收到了这个错误。任何线索?
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
你应该在 system.js
中添加 ng2material
作为
var map = {
'ng2-material': 'node_modules/ng2-material',
};
var packages = {
'ng2-material': {defaultExtension: 'js'},
};
我遇到了类似的问题。 Angular 的新编译器-cli 似乎有问题。我通过在 package.json
中的 devDependencies
中添加以下内容来解决它
"@angular/compiler-cli": "^2.0.0"
再次执行 npm install
后,错误消失了。
我是 angular2
和 material-design
的新人。我正在尝试将它们一起使用。
我cloned
这个material2-app,这是基于angular2
和material2
和运行npm install
的应用程序代码。
当我运行这个命令npm start
启动一个服务器。我收到了这个错误。任何线索?
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
你应该在 system.js
中添加 ng2material作为
var map = {
'ng2-material': 'node_modules/ng2-material',
};
var packages = {
'ng2-material': {defaultExtension: 'js'},
};
我遇到了类似的问题。 Angular 的新编译器-cli 似乎有问题。我通过在 package.json
devDependencies
中添加以下内容来解决它
"@angular/compiler-cli": "^2.0.0"
再次执行 npm install
后,错误消失了。