标签: angular-cli

angular-cli"ng build"不会产生工作项目?

(我是星球Angular2的新手(从垂死的行星
Flex/Actionscript 移民,所以请原谅这个天真的问题)

在我的项目中运行"ng build"命令后,我发现了一个致命的错误Angular CLi,我最终会在"dist"目录中运行一个正常运行的项目 - 我可以在浏览器中运行,放在一个服务器?

我最终得到了一个充满正确命名的东西的文件夹,等等.我在这里缺少一步吗?

在此输入图像描述

angular-cli angular

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

有没有办法告诉angular-cli(for angular 2)生成缩小版的css?

正如标题所说,当我运行"ng serve"时,angular-cli会产生正常的css,而我希望得到缩小的版本.是否有任何特定的设置用于angular-cli-build,或者一些额外的插件来安装和使用?

这是我的angular-cli-build.js

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');


module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/**/*.+(js|js.map)',
      'es6-shim/es6-shim.js',
      'reflect-metadata/**/*.+(ts|js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      'angular2-cookie/**/*.js'
    ]
  });
};
Run Code Online (Sandbox Code Playgroud)

css angular-cli angular

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

运行ng服务时文件存储在哪里?

当我运行时ng serve,文件生成和存储在哪里?我需要解决应用程序的原因,ng serve但不能解决生产构建问题.

忘记提到我正在使用angular-cli的webpack版本.

angular-cli angular

21
推荐指数
1
解决办法
6608
查看次数

使用switch时,tslint抱怨"语句必须使用if语句进行过滤"

可以说我有以下方法:

getErrorMessage(state: any, thingName?: string) {
    const thing: string = state.path || thingName;
    const messages: string[] = [];
    if (state.errors) {
        for (const errorName in state.errors) {
            switch (errorName) {
                case 'required':
                    messages.push(`You must enter a ${thing}`);
                    break;
                case 'minlength':
                    messages.push(`A ${thing} must be at least ${state.errors['minlength'].requiredLength}characters`);
                    break;
                case 'pattern':
                    messages.push(`The ${thing} contains illegal characters`);
                    break;
                case 'validateCardNumberWithAlgo':
                    messages.push(`Card doesnt pass algo`);
                    break;
            }
        }
    }
    return messages;
}
Run Code Online (Sandbox Code Playgroud)

我跑的时候

ng lint
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

for(... in ...)语句必须使用if语句进行过滤

看一下类似的问题,我认为答案不适用于我的情况.所有switch语句都在if-else-if阶段的类别中.

tslint应该将switch语句视为if语句的形式,但它没有?!

typescript tslint angular-cli angular

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

无法使用npm安装@ angular/cli

我是"@ angular/cli"的新手,我已经尝试过所有东西但无法安装.我现在很累,请有人帮我在我的系统中安装角度4"@ angular/cli".

节点和npm版本 在此输入图像描述

当我安装"npm install -g @ angular/cli"然后获取 在此输入图像描述

在安装节点-v 6之后我得到了erorr 在此输入图像描述

请告诉我实际上我错了.

node.js typescript npm-install angular-cli angular

21
推荐指数
3
解决办法
4万
查看次数

由于require-from-string而使用npm安装Angular时出错

如何解决此错误,因为我无法安装Angular.

请参阅以下例外:

C:\Users\absin\node>npm install -g @angular/cli
npm ERR! code ETARGET
npm ERR! notarget No matching version found for require-from-string@^1.1.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'cosmiconfig'
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\absin\AppData\Roaming\npm-cache\_logs\2018-01-06T19_07_00_000Z-debug.log
Run Code Online (Sandbox Code Playgroud)

即使在时间解决之后:

npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm …
Run Code Online (Sandbox Code Playgroud)

install node.js angular-cli angular

21
推荐指数
2
解决办法
3470
查看次数

使用SCSS/Sass作为Angular 6+(styleExt)中的默认样式表

显然,声明默认样式表扩展的方式从Angular 6开始改变了.该styleExt物业angular.json不再被承认.

对于新的项目,这可以通过在命令行选项来设置--style=scss的new命令.

但是,如何在我从Angular <5迁移的项目或者在项目创建期间忘记执行此操作时更改此项目?

这个问题与Angular第5版到第6版的重大变化有关.

css sass angular-cli angular angular6

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

在 Mac 操作系统上找不到 Angular CLI ng 命令

我查看了此处有关此问题的大量帖子并尝试了它们,但没有成功解决此问题。

我在 MacOS 上,这是我迄今为止根据我在此处找到的建议所做的工作,但我仍然收到此错误

 ~~ sudo npm uninstall -g angular-cli

 ~~ sudo npm uninstall -g @angular/cli

 ~~ sudo npm cache clean --force

 ~~ sudo npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

这输出:

/usr/local/Cellar/node/11.10.0/bin/ng -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli/bin/ng

> @angular/cli@8.3.6 postinstall /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js

+ @angular/cli@8.3.6
added 245 packages from 185 contributors in 8.784s
Run Code Online (Sandbox Code Playgroud)

但是,发出以下命令不起作用:

 ~~ ng version

-bash: ng: command not found
Run Code Online (Sandbox Code Playgroud)

有些人建议链接,所以我也尝试过:

 ~~ sudo npm link @angular/cli
Run Code Online (Sandbox Code Playgroud)

,输出如下:

/Users/dinob/node_modules/@angular/cli -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli
Run Code Online (Sandbox Code Playgroud)

,但 ng 版本仍然无法正常工作:

 ~~ ng version

-bash: ng: command not found
Run Code Online (Sandbox Code Playgroud)

许多帖子建议 …

macos angular-cli

21
推荐指数
3
解决办法
3万
查看次数

安装 ng add @ng-bootstrap/ng-bootstrap 时出错

将 ng-bootstrap 安装到我的 Angular-CLI(11.0.4) 时出现错误。什么时候

ng add @ng-bootstrap/ng-bootstrap 
Run Code Online (Sandbox Code Playgroud)

还有我的日志文件

[error] Error: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: front@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~11.0.4" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.1" from @angular/localize@11.1.1
npm ERR! node_modules/@angular/localize
npm ERR!   peer @angular/localize@"^11.0.0" from @ng-bootstrap/ng-bootstrap@9.0.2
npm ERR!   node_modules/@ng-bootstrap/ng-bootstrap
npm ERR!     @ng-bootstrap/ng-bootstrap@"*" from the root project
npm ERR! 
npm …
Run Code Online (Sandbox Code Playgroud)

terminal npm angular-cli ng-bootstrap angular

21
推荐指数
4
解决办法
4万
查看次数

升级到 Angular 13 后,使用 --code-coverage 的测试失败

升级到 Angular 13 后,使用--code-coverage运行的测试失败,并出现缺少某些插件的错误

\n

我正在使用karma-coverage-istanbul-reporter,karma.conf.js这导致了一些问题。我什至将其替换为默认值karma-coverage,但仍然看到相同的错误

\n
ng test waxion --no-watch --code-coverage --browsers ChromeHeadless\n
Run Code Online (Sandbox Code Playgroud)\n
\xe2\xa0\x8b Generating browser application bundles (phase: setup)...20 11 2021 17:34:24.723:ERROR [reporter]: Can not load reporter "coverage", it is not registered!\n  Perhaps you are missing some plugin?\n\xe2\xa0\x99 Generating browser application bundles (phase: building)...20 11 2021 17:34:27.353:INFO [karma-server]: Karma v6.3.9 server started at http://localhost:9876/\n20 11 2021 17:34:27.353:INFO [launcher]: Launching browsers Chrome with concurrency unlimited\n20 11 2021 17:34:27.353:ERROR [karma-server]: Error: Found …
Run Code Online (Sandbox Code Playgroud)

karma-jasmine karma-coverage angular-cli

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