标签: angular-cli

构建角度库时包含资产

我正在构建一个包含自定义图标字体的库。但是,当我使用 构建我的库时ng build <library-name> --prod,资产文件夹不包含在构建中,这意味着使用生产构建时不会显示图标。

我尝试了多种解决方案,例如添加assets数组angular.json并将资产文件夹复制到创建的 dist 文件夹。

我使用的是 Angular 8,该库是使用 angular-cli 创建的。

我尝试以两种方式包含字体:@import url( '../assets/icon_font.css' );在样式文件之一中使用并../assets/icon_font.css在需要它的组件之一中添加到 styleUrls。(icon_font.css是包含图标字体的 css 文件)

这是我的库目录的布局:

- src
  - lib
    - assets
      - icon_font.css
      - font files
    - component that requires icons
      - style sheet that has @import icon_font.css
    - other components and classes
Run Code Online (Sandbox Code Playgroud)

我希望assets/目录中的 .ttf 和其他字体文件在导出的dist文件夹中可用。

assets angular-cli angular angular-library ng-packagr

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

'compilation' 参数必须是 Compilation 的实例

在我的 Angular 12.0.2 项目上运行“ng build”时出现此错误

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: The 'compilation' argument must be an instance of Compilation
    at getCompilationHooks (D:\Dev\Git_Merc\mercury\node_modules\webpack\lib\javascript\JavascriptModulesPlugin.js:125:10)
    at D:\Dev\Git_Merc\mercury\node_modules\webpack\lib\javascript\CommonJsChunkFormatPlugin.js:43:19
    at Hook.eval [as call] (eval at create (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at Hook.CALL_DELEGATE [as _call] (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\Hook.js:14:14)
    at Compiler.newCompilation (D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:1030:30)
    at D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:1073:29
    at Hook.eval [as callAsync] (eval at create (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\Dev\Git_Merc\mercury\node_modules\tapable\lib\Hook.js:18:14)
    at Compiler.compile (D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:1068:28)
    at Compiler.runAsChild (D:\Dev\Git_Merc\mercury\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:520:8)
Run Code Online (Sandbox Code Playgroud)

我一直在谷歌上搜索,但找不到任何可以解决我的问题的东西。我不确定是什么触发了这个。

版本:

Angular CLI: 12.0.2
Node: 14.17.0
Package Manager: npm 7.14.0
OS: win32 …
Run Code Online (Sandbox Code Playgroud)

angular-cli

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

Angular cli更新后获取错误

我的angular-cli版本是beta.16

我尝试通过以下命令更新

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)

在我尝试运行任何ng命令后成功安装

ng version 
ng help
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误

ng help
/usr/local/lib/node_modules/@angular/cli/models/config/config.js:15
    constructor(_configPath, schema, configJson, fallbacks = []) {
                                                           ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/models/config.js:2:18)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
Run Code Online (Sandbox Code Playgroud)

angular-cli

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

IE11 Angular 2错误"预期的标识符,字符串或数字"

好吧,我使用Angular 2创建了网站.当我运行"ng-serve"命令并尝试在Google Chrome和IE11中使用" http:// localhost:4200 " 测试我的网站时,它运行正常,但是,如果我构建项目使用"ng-build --prod",在IIS上托管它.网站仍在Chrome上运行,但IE11显示以下错误: 预期的标识符,字符串或数字

我用谷歌搜索它,发现它可能是我的标识符键中的保留字:值对.所以我在钥匙上添加了Apostrophes(').例如,我有以下对象:

user:UserViewModel={
    Username:"",
    Age:0
};
and changed this to:
user:UserViewModel={
    'Username':"",
    'Age':0
};
Run Code Online (Sandbox Code Playgroud)

还删除了key:value对中的最后一个逗号,并在polyfills.ts中导入了core.js

iis typescript internet-explorer-11 angular-cli angular

22
推荐指数
2
解决办法
6750
查看次数

什么--minimal做的角度cli` ng new`?

Angular CLI有一个名为的选项--minimal.它做了什么以及在哪里记录?该命令ng help new对此几乎没有说明

--minimal (Boolean) (Default: false) Should create a minimal app.
  aliases: --minimal
Run Code Online (Sandbox Code Playgroud)

angular-cli

22
推荐指数
2
解决办法
8083
查看次数

无法重新声明块范围变量'ngDevMode'

我在Angular 5上的应用程序.这是package.json的样子

{
  "name": "myapp",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@types/file-saver": "0.0.1",
    "angular-2-dropdown-multiselect": "^1.6.0",
    "angular2-csv": "^0.2.5",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.3",
    "ngx-bootstrap": "^1.9.3",
    "ngx-clipboard": "^8.1.0",
    "ngx-loading": "^1.0.14",
    "ngx-pagination": "^3.0.0",
    "ngx-toastr": "^6.4.0",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

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

如何使用Angular CLI删除包?

Angular 6有新的CLI命令ng add <package>.

如何使用Angular CLI删除软件包?

UPDATE

文件

ng add 将使用您的包管理器下载新的依赖项并调用安装脚本(实现为原理图),该脚本可以通过配置更改更新项目,添加其他依赖项(例如polyfill)或scaffold特定于程序包的初始化代码

它不一样 npm install <package>

我试图使用,ng rm但它还没有工作.

angular-cli angular

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

生成期间从运行时错误 - 生成错误

我更新了Angular的所有内容,当我
"Build --prod" 时,我现在得到下面的错误(4x)

如果我删除--prod没有错误

我在这个应用程序中没有真正的代码.它只是一个入门外壳.

关于要研究什么的任何建议?

ERROR in runtime.82c6613acef8f7246fe8.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/Users/puser/Dropbox/AngularApps/GenesisFYI-v06/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
    at module.exports (/Users/puser/Dropbox/AngularApps/GenesisFYI-v06/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
    at handle (/Users/puser/Dropbox/AngularApps/GenesisFYI-v06/node_modules/worker-farm/lib/child/index.js:44:8)
    at process.<anonymous> (/Users/puser/Dropbox/AngularApps/GenesisFYI-v06/node_modules/worker-farm/lib/child/index.js:51:3)
    at process.emit (events.js:197:13)
    at emit (internal/child_process.js:828:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
Run Code Online (Sandbox Code Playgroud)

我目前的版本

Angular CLI: 7.3.0  
Node: 11.8.0  
OS: darwin x64  
Angular: 7.2.3  
... animations, common, compiler, compiler-cli, core, forms  
... http, language-service, platform-browser  
... platform-browser-dynamic, router, service-worker  

Package                           Version  
-----------------------------------------------------------  
@angular-devkit/architect         0.13.0  
@angular-devkit/build-angular     0.13.0  
@angular-devkit/build-optimizer   0.13.0  
@angular-devkit/build-webpack     0.13.0  
@angular-devkit/core              0.6.8  
@angular-devkit/schematics …
Run Code Online (Sandbox Code Playgroud)

webpack angular-cli angular

22
推荐指数
2
解决办法
3832
查看次数

有没有办法告诉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万
查看次数

无法使用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万
查看次数