使用 angular-cli 命令 ng-serve 运行 angular2 应用程序时,我遇到以下问题
仪表板@0.0.0开始C:\ Users \ padmavathi \ Downloads \ phototype-development \ web \仪表板ng服务
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8980:109)
at parseSourceFileWorker (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8940:26)
at Object.parseSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8899:26)
at Object.createSourceFile (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\typescript\lib\typescript.js:8727:29)
at new TypeScriptFileRefactor (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\refactor.js:25:35)
at Object.resolveEntryModuleFromMain (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\entry_resolver.js:108:18)
at AotPlugin._setupOptions (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\plugin.js:129:58)
at new AotPlugin (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\@ngtools\webpack\src\plugin.js:37:14)
at Object.exports.getWebpackNonAotConfigPartial (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\angular-cli\models\webpack-build-typescript.js:20:13)
at new NgCliWebpackConfig (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\angular-cli\models\webpack-config.js:23:42)
at Class.run (C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\angular-cli\tasks\serve-webpack.js:20:22)
at C:\Users\padmavathi\Downloads\phototype-development\web\dashboard\node_modules\angular-cli\commands\serve.js:102:26
at process._tickCallback (internal/process/next_tick.js:103:7)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program …Run Code Online (Sandbox Code Playgroud) 所以我完成了一个非常小的 angular2 项目,并使用命令“ng build --prod”通过 angular-cli 构建它。
我从中得到一个“dist”文件夹。但是我应该如何处理这个 dist 文件夹才能使其运行?将其发布到服务器?
问候。
我需要关闭 Angular CLIng build命令输出中的颜色,即它完成时写入控制台的摘要。有没有某种方法(最好是环境变量或命令行参数)来禁用它?
Angular2 cli项目生产构建[ng build -prod]遇到 92% 的问题,并收到诸如堆内存耗尽之类的错误消息。有什么解决办法吗?项目由大量组件组成。正常构建工作正常[ng build]
谢谢
我正在使用 angular-cli 为管理菜单编写一些代码,我需要显示访问者数量。我在互联网上进行了搜索,但找不到解决方案。知道如何为我的 Angular 2 或 Angular-CLI 应用程序制作访客计数器吗?
当我尝试构建产品(ng build --prod)时,我的角度项目无法构建。请注意ng build似乎工作正常。
当我尝试使用 --prod 选项构建时出现以下错误
Error: ENOENT: no such file or directory, mkdir 'C:\dev\workspaces\intellij-workspaces\myproject\web\target\frontend'
at Error (native)
at Object.fs.mkdirSync (fs.js:922:18)
Run Code Online (Sandbox Code Playgroud)
我已将 Angular-cli outDir 设置如下
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "web"
},
"apps": [
{
"root": "src",
"outDir": "../../../target/frontend",
"deployUrl": "myproject-dashboard/",
"assets": [
"assets",
"favicon.ico"
],
Run Code Online (Sandbox Code Playgroud)
我的 package.json 和 angular-cli.json 文件位于 myproject/web/src/main/frontend 下
因此,理想情况下,基于 angular-cli.json 中为 outDir 设置的相对路径,我希望在myproject/web文件夹下创建一个名为 target 的文件夹,并且我的所有构建输出都可以在那里使用。
请您告诉我是否应该手动创建目标文件夹,或者是否有办法告诉 angular-cli 自动创建它?
我有一个PhoneNumbersFormComponent其模板如下所示:
<div [formGroup]="form">
<div formArrayName="numbers">
<input formControlName="countryPrefix">
<input formControlName="number">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想通过 angular-cli 创建的默认测试ng g component xxx
我得到的第一个错误是:
找不到名称为“countryPrefix”的控件
我用以下方法解决了这个问题:
beforeEach(() => {
fixture = TestBed.createComponent(PhoneNumbersFormComponent);
component = fixture.componentInstance;
component.phoneNumbers = [];
component.form = new FormGroup({
countryPrefix: new FormControl(),
number: new FormControl()
});
fixture.detectChanges();
});
Run Code Online (Sandbox Code Playgroud)
现在剩下的最后一个错误是:
找不到名称为“numbers”的控件
我不知道如何测试formArrayName="numbers"
我正在尝试使用以下命令 ng build --env=uat --prod -bh / 构建 Angular cli (版本 5 )应用程序
我收到错误“环境“uat”不存在”。
我在 angular-cli.json 中有以下几行
` "scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"uat": "environments/environment.uat.ts"
}`
Run Code Online (Sandbox Code Playgroud)
我创建了文件environments/environment.uat.ts。
您能让我知道问题可能是什么吗?
我编写了一个脚本来截取我的角度应用程序的屏幕截图。问题是,只有当我在脚本之前手动启动 ng 服务时,该脚本才有效。我的问题是,如果开发服务器已启动并正在运行,我可以告诉 ngserve 启动脚本吗?我尝试过ng serve && node screenshot-generation.js,但屏幕截图生成脚本未执行,因为 ng 服务尚未完成。
感谢您的帮助。
我注意到我安装了本地和全局 Angular/cli 软件包。
与全局包相比,何时使用 Angular/cli 本地包?
angular ×10
angular-cli ×10
node.js ×2
typescript ×2
angular2-cli ×1
build ×1
npm ×1
publish ×1
unit-testing ×1