标签: angular-cli

无法在 Ubuntu 16.04 中安装 Angular CLI

我无法在 Ubuntu 16.04 中安装 Angular CLI。进入后sudo npm install-g angular-cli,加载和写入需要很长时间。

npm ERR! Linux 4.13.0-37-generic 
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "angular-cli" 
npm ERR! node v4.2.6 
npm ERR! npm v3.5.2 
npm ERR! path /usr/local/bin/ng 
npm ERR! code EEXIST 
npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/@angular/cli/bin/ng symlink target is not controlled by npm /usr/local 
npm ERR! File exists: /usr/local/bin/ng 
npm ERR! Move it away, and try again. 
npm ERR! Please include the following file with any support request: 
npm ERR! …
Run Code Online (Sandbox Code Playgroud)

node.js angular-cli angular

2
推荐指数
1
解决办法
6053
查看次数

如何在自定义 Angular Schematics 中定位文件路径?

我目前正在尝试创建自己的自定义 Angular Schematics。我有以下内容:

import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';


// You don't have to export the function as default. You can also have more than one rule factory
// per file.
export function pxSchematics(options: any): Rule {
  return (tree: Tree, _context: SchematicContext) => {
    tree.create(options.name || 'hello', 'world');
    return tree;
  };
}
Run Code Online (Sandbox Code Playgroud)

它只是创建一个带有“hello world”的文件。我将如何更改树的文件路径,以便它在自定义目录中输出文件?谢谢。

angular-cli angular angular-schematics

2
推荐指数
1
解决办法
2189
查看次数

如何将 google.visualization 类型与 Angular CLI 结合使用?

我正在尝试在 Angular CLI (7.2.3) 项目中使用 Google Charts,但在输入内容时遇到问题。

首先,我使用此命令安装了类型(带或不带 -dev 标志):

npm install --save-dev @types/google.visualization

执行此操作后,智能感知立即开始在 Visual Studio Code 中工作,并且当我创建如下简单测试时,我没有收到任何突出显示的错误:

const chartBoxStyle: google.visualization.ChartBoxStyle = {};
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试通过运行ng build进行构建时,出现以下错误:

错误 TS2503:找不到命名空间“google”。

我尝试将其添加到我的文件中,但没有成功:

declare const google: any;
Run Code Online (Sandbox Code Playgroud)

我的 tsconfig.json 文件具有以下 typeRoots 内容,我在其中看到 google.visualization 文件夹:

"typeRoots": ["node_modules/@types"]
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激,因为我不知道如何克服这一点。

typescript angular-cli typescript-typings angular

2
推荐指数
1
解决办法
1419
查看次数

在 localhost:4200 中找不到 404

我试图将数据从“ http://localhost:8082/api/kanchiwork/ ”传递到“ http://localhost:4200/ ”。我的 proxy.config.json 文件是:

    {
      "context": [
        "/api/**"
      ],
      "pathRewrite": {
        "^/api": ""
      },
      "ws": false,
      "target": "http://localhost:8082",
      "secure": false,
      "changeOrigin": true,
      "logLevel": "debug"
    }
  ]
Run Code Online (Sandbox Code Playgroud)

我的服务文件如下。

import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class PeopleService {

  constructor(private http:HttpClient) { }

  fetchPeople(): Observable<Object>{
    return this.http.get('/api/kanchiwork/');
    //return this.http.get('assets/response.json');
  };

}
Run Code Online (Sandbox Code Playgroud)

。当我尝试传递值时,我在控制台中收到消息“GET localhost:4200/api/kanchiwork 404 (Not Found)”。

api angular-cli angular

2
推荐指数
1
解决办法
9187
查看次数

执行 ngserve 时“wdm”是什么?

每当我在 Angular 项目中使用时ng serve,我都会得到如下所示的控制台输出:

\n
i \xef\xbd\xa2wdm\xef\xbd\xa3: Compiled successfully.\n
Run Code Online (Sandbox Code Playgroud)\n

我一直在寻找关于wdm到底是什么的解释,但到目前为止什么也没找到。有人有什么主意吗?

\n

angular-cli angular

2
推荐指数
1
解决办法
610
查看次数

错误 TS2440:导入声明与“Highcharts3d”的本地声明冲突

我尝试在 VS code 中运行我的应用程序,但不断收到错误:

error TS2440: Import declaration conflicts with local declaration of 'Highcharts3d'
Run Code Online (Sandbox Code Playgroud)

请帮助我修复这个错误

    import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
    import * as Highcharts from 'highcharts';
    import * as Highcharts3d from "highcharts/highcharts-3d";
    
    declare var require: any
    
    let Highcharts3d:any = require("highcharts/highcharts-3d");
    let HighchartsExporting = require("highcharts/modules/exporting"); 

    Highcharts3d(Highcharts);
Run Code Online (Sandbox Code Playgroud)

highcharts typescript angular-material angular-cli

2
推荐指数
1
解决办法
2万
查看次数

如何解决 npm run build 137 错误?已经设置10gb了

我正在运行 npm run build 来创建一个 docker。它有 --prod 选项。如果没有 --prod 运行,它构建得很好。如果使用 --prod 构建,则会出现 137 ENDLIFECYCLE 错误。

杀死 npm 错误!代码 ELIFECYCLE npm 错误!错误号137

不幸的是,我不能只删除 prod 选项,因为这就是在开发机器上运行的选项,而我只是应该进行 devops。

我看到很多地方都是因为内存不足,所以我设置了变量 NODE_OPTIONS --max-old-space-size

目前它的容量为 10GB,但没有帮助。我可以在我的机器上用 8GB 构建相同的 docker。

这个构建发生在 jenkins 内部,我在 docker 内部做了一个 free -m 只是为了看看,服务器有 64GB 内存。

那么可能是什么问题呢?

node.js npm jenkins docker angular-cli

2
推荐指数
1
解决办法
1万
查看次数

AWS 中的 codeBuild ng 构建失败,并显示“Javascript 超出堆内存”

我正在为我的 angular-7 项目使用 AWS 代码构建。我在现有项目中安装 AWS-amplify,但在构建 AWS 服务 (codeBuild) 时出现以下错误。

ng build --prod:Javascript 堆内存不足

本地构建运行成功,但不知道管道(codeBuild)阶段失败的真正原因。

尝试了 StackOverflow 的一些帮助以及类似这个问题的帮助,但一切都是徒劳的。知道为什么 AWS 代码构建会出现此问题而不是本地代码构建吗?以及解决方案来摆脱此问题。谢谢

amazon-web-services angular-cli aws-codebuild

2
推荐指数
1
解决办法
3938
查看次数

使用 Angular 13 安装 ngrx 存储时出现错误,无法解析依赖关系树

我在使用此命令时遇到问题:

ng add @ngrx/store@latest
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: ngstore-app@0.0.0
npm ERR! Found: @angular/core@13.0.0
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"~13.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"^12.0.0" from @ngrx/store@12.5.1
npm ERR! node_modules/@ngrx/store
npm ERR!   @ngrx/store@"12.5.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or …
Run Code Online (Sandbox Code Playgroud)

node.js npm angular-cli angular

2
推荐指数
1
解决办法
6066
查看次数

Angular 构建 - 索引 html 生成失败。未定义:9:219187:属性缺少“:”

我有一个 Angular 应用程序,它似乎不是使用产品配置构建的。我收到以下错误:

 Index html generation failed.
 undefined:9:219187: property missing ':'
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! JI.Infopool.WebApp@0.0.0 build: `ng build --outputHashing=all "--configuration=prod"`
 npm ERR! Exit status 1
 npm ERR!
 npm ERR! Failed at the JI.Infopool.WebApp@0.0.0 build script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)

正常的构建工作正常,我认为我没有更改任何运行配置。我在日志文件中也找不到任何有用的内容。这是 angular.json 文件中的配置:

"prod": {
          "baseHref": "/myApp/",
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false, …
Run Code Online (Sandbox Code Playgroud)

node.js angular-cli ng-build

2
推荐指数
1
解决办法
2273
查看次数