【发布时间】:2017-01-10 00:24:57
【问题描述】:
我刚刚将我的项目更新到 Angular 2 RC 6。我现在正尝试使用博文 http://angularjs.blogspot.com/ 中提到的提前 (AoT) 编译,但没有成功。
我在 ASP.Net 中构建项目时没有使用 angular cli。
正如博文所说,我已经安装了@angular/compiler-cli
但是当我尝试从命令提示符运行 ngc 时,它给出了错误
'ngc' is not recognized as an internal or external command,
operable program or batch file.
npm run ngc
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ngc"
npm ERR! node v6.4.0
npm ERR! npm v3.10.3
npm ERR! missing script: ngc
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! D:\Project\App\npm-debug.log
谁能指导如何在 ASP.Net 项目中使用 AoT 编译器。或者当您不使用 Angular CLI 而是手动构建组件等时。
编辑
我现在设法通过首先移动到 ./node_modules/.bin/ 然后运行
来运行 ngcngc -p D:\Project\App
但是现在编译器抛出以下错误:
当我尝试用 ngc 编译我的项目时,它会抛出以下错误:
Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 92:25 in the original .ts file), resolving symbol AppModule in
在我的应用程序模块中,我有以下提供程序,这可能是导致该项目的原因。我不确定这到底有什么问题?
providers: [
GlobalService,
{
provide: Http,
useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, globalService: GlobalService) => new HttpLoading(backend, defaultOptions, globalService),
deps: [XHRBackend, RequestOptions, GlobalService]
}
],
【问题讨论】:
-
如果您查看答案,这是一个 Windows 问题,您的 PATH 可能已经搞砸了,或者您需要重新启动,甚至以管理员身份打开 CMD。不幸的是,这可能是很多事情。试一试!
-
感谢 Mark 的回复,您能看看我对这个问题所做的编辑吗?
标签: angular angular2-services angular2-compiler