标签: angular-cli

将服务器端代码添加到angular-cli项目与节点类型冲突

将基本的express.js配置(使用TypeScript)添加到使用angular-cli初始化的Angular2项目时ng new [project-name],我需要添加以下类型以使用gulp编译快速服务器:

typings安装--ambient --save node

这会将以下行添加到typings/browser.d.ts和typings/main.d.ts

/// <reference path="browser/ambient/node/index.d.ts" />
and
/// <reference path="main/ambient/node/index.d.ts" />
Run Code Online (Sandbox Code Playgroud)

在快递server.ts文件中,我可以添加引用main而不是browser保持TypeScript快乐

/// <reference path="../typings/main.d.ts" />
Run Code Online (Sandbox Code Playgroud)

但是当我将节点输入引用留在browser.d.ts文件中时,该ng build命令将失败:

Build failed.
The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: Typescript found the following errors:
  C:/Users/user123/Downloads/my-catalog-master/my-catalog-master/tmp/broccoli_type_script_compiler-input_base_path-7VFCE2dg.tmp/0/src/typings.d.ts (3, 13): Subsequent variable declarations must have the same type.  Variable 'module' must be of type 'NodeModule', but here has type '{ id: string; }'. …
Run Code Online (Sandbox Code Playgroud)

node.js typescript angular-cli angular

8
推荐指数
1
解决办法
1421
查看次数

使用具有角度2 cli的基础6 scss

如何使用角度cli的基础6.I尝试使用普通的scss但是无法继续使用基础6 scss.我该如何处理这个问题.提前致谢.

zurb-foundation-6 angular-cli angular

8
推荐指数
2
解决办法
6249
查看次数

Angular-CLI和ThreeJS

我一直在尝试添加正确的npm依赖项来将THREE添加到我的Angular-CLI项目中.随着CLI在过去几个月变化如此之快,我找不到工作来源.

这里有一些想法......

  • 背驮式脚本

    这是我的第一次尝试,只需添加<script src="three.js"></script>到index.html文件即可.但是我在打字稿界面中使用javascript时遇到了麻烦.

  • 的WebPack

    这是我的第二次尝试,但我遇到了几个文档问题.Angular-cli似乎没有使用webpacks的一致方法.实现webpack有四种不同的方法.我无法与三人合作.

  • 捆绑

    这似乎是一个黑客,一个穷人/冗长的人.将捆绑包添加到THREE库中,以便可以将其解释为角度2.

我目前仍在制作Angluar-CLI + THREE.js项目.如果我在下周没有看到进展,我可能会放弃角度cli.任何建议/来源将不胜感激.

three.js angular-cli angular

8
推荐指数
1
解决办法
7115
查看次数

如何在ng build之前运行ng测试 - 当ng测试失败时,使用jenkins作业失败?

之前我使用了angular-cli的systemJS版本,每当我从jenkins开始构建时,如果有任何测试用例失败,那么构建过去就会失败.

我只是ng build --prod命令建立我的项目.

现在使用angular-cli的webpack版本,我们必须明确地运行ng test.

如何检查jenkins是否ng test 已成功并继续使用ng build --prod或者构建失败?

jenkins angular-cli angular

8
推荐指数
1
解决办法
2915
查看次数

Angular:当我创建一个 Angular 项目时出现新错误

使用ng new project_name 时出现此错误:

发现无效的配置文件 ['angular.json']。请在运行命令前删除该文件。

我收到此错误我不知道如何获得解决方案。

我卸载了@angular/cli 并再次安装

npm clean cache 也不起作用(我不知道是不是我的 npm 版本的问题

npm version is 6.4.1    
node version is 8.11.1
Run Code Online (Sandbox Code Playgroud)

我需要什么来解决问题?

node.js angular-cli angular

8
推荐指数
1
解决办法
9529
查看次数

ng build --prod 非常慢

我们有一个 Angular 项目,我们正在尝试使用--prod选项构建它。

问题是,花了33个小时!

老实说,我们不太擅长 Angular、npm 等等,我们都是这个世界的初学者。

我们所知道的是,当我们执行 时ng build --prod command,我们会卡在这里几个小时:

11% building modules 9/11 modules 2 active …s\font-awesome\css\font-awesome.min.css
Run Code Online (Sandbox Code Playgroud)

我们尝试从angular.json文件中删除 font-awesome.min.css,但是我们卡在另一个 CSS 文件中,而且它永远不会结束。即使我们从angular.json文件中删除了所有 CSS文件,我们仍然卡在这里:

10% building modules 2/2 modules 0 active
Run Code Online (Sandbox Code Playgroud)

以下是我们的版本:

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.7.5
@angular-devkit/build-angular      0.7.5
@angular-devkit/build-ng-packagr   0.7.5
@angular-devkit/build-optimizer    0.7.5
@angular-devkit/build-webpack      0.7.5
@angular-devkit/core               0.7.5
@angular-devkit/schematics         0.8.9
@angular/cdk                       6.4.7
@angular/cli                       6.2.9
@angular/material                  6.4.7
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.1.5
@schematics/angular                0.8.9
@schematics/update                 0.8.9
ng-packagr                         4.7.1
rxjs                               6.4.0
typescript                         2.9.2
webpack                            4.9.2 …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

8
推荐指数
2
解决办法
9356
查看次数

错误:找不到模块'@angular/compiler-cli

执行ng s --open命令时出现以下错误:

找不到模块 '@angular/compiler-cli' 错误:在 Function.Module._resolveFilename (internal/modules/cjs/loader.js:655:15) 的 Function.Module 中找不到模块 '@angular/compiler-cli'。 _load (internal/modules/cjs/loader.js:580:25) at Module.require (internal/modules/cjs/loader.js:711:19) at require (internal/modules/cjs/helpers.js:14: 16)在对象。(G:\Front-End\angular\rapydly\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:12:24) at Module._compile (internal/modules/cjs/loader.js:805:30) at Object。 Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader .js:612:12) 在 Function.Module._load (internal/modules/cjs/loader.js:604:3) 在 Module.require (internal/modules/cjs/loader.js:711: 19) 在对象的 require (internal/modules/cjs/helpers.js:14:16)。(G:\Front-End\angular\rapydly\node_modules@ngtools\webpack\src\index.js:13:10) 在 Module._compile (internal/modules/cjs/loader.js:805:30) 在 Object。 Module._extensions..js (internal/modules/cjs/loader.js:816:10) at Module.load (internal/modules/cjs/loader.js:672:32) at tryModuleLoad (internal/modules/cjs/loader .js:612:12) at Function.Module._load (internal/modules/cjs/loader.js:604:3) at Module.require (internal/modules/cjs/loader.js:711:19) at require ( internal/modules/cjs/helpers.js:14:16) 在对象。(G:\Front-End\angular\rapydly\node_modules@angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\typescript.js:4:19) 在 Module._compile (internal /modules/cjs/loader.js:805:30) \Front-End\angular\rapydly\node_modules@ngtools\webpack\src\index.js:13:10) 在 Module._compile (internal/modules/cjs/loader.js:805:30) …

angular-cli angular

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

角度更新后的 Bootstrap SCSS 错误

我最近将我的项目从 angular 版本 7 升级到 8。但是当我发出命令时,npm start我看到了很多与Bootstrap.

WARNING: You probably don't mean to use the color value gray in interpolation here.
It may end up represented as gray, which will likely produce invalid CSS.
Always quote color names when using them as strings or map keys (for example, "gray").
If you really want to use the color value here, use '"" + $color'.

   ?
48 ?   .alert-#{$color} {
   ?            ^^^^^^
   ?
    node_modules/bootstrap/scss/_alert.scss 48:12  @import
    src/scss/bootstrap.scss 46:9 …
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap angular-cli ng-bootstrap angular angular-devkit

8
推荐指数
1
解决办法
1936
查看次数

使用 Angular 中的源映射生成生产版本 - CLI

生产构建后如何保留源映射?

现在,我的命令如下所示:

"build-prod": "ng build --app=release -prod && cp -R lang dist"

我尝试将其更改为:

ng build --app=release --sourceMap=true -prod && cp -R lang dist

但什么都没有改变。

如果我这样做: ng build --sourcemap我得到了源映射,但随后我得到了 index.html 而不是 index.prod.html。

是否可以编辑第一个命令来构建源映射文件?

这是我的tsconfig.json文件:

{
    "compileOnSave": false,
    "compilerOptions": {
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
            "node_modules/@types"
        ],
        "lib": [
            "es2017",
            "dom"
        ]
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript angular-cli angular

8
推荐指数
2
解决办法
7219
查看次数

Angular (7) 组件只接受 html 文件

组件定义如下:

import {Component} from '@angular/core';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less']
})
export class AppComponent {

}
Run Code Online (Sandbox Code Playgroud)

我想加载一些特定的组件而不是“app.component.html”扩展名为“app.component.htm”的文件

@Component({
  selector: 'app-root',
  templateUrl: './app.component.htm',
  styleUrls: ['./app.component.less']
})
Run Code Online (Sandbox Code Playgroud)

由于某种原因它不起作用它说:

ERROR in ./app.component.htm 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
<p>
  app component works!
</p>
?wdm?: Failed to compile. 
Run Code Online (Sandbox Code Playgroud)

请帮我找到一种加载htm文件的方法?我知道有一种方法可以使用 Webpack 进行引导,我想保留 ng-serve\cli angular.json 的当前版本!

谢谢!

angular-cli angular

8
推荐指数
1
解决办法
1851
查看次数