标签: angular10

Angular 10 升级 - 修复 CommonJS 或 AMD 依赖项可能导致优化救助

我正在尝试将我的 Angular 9 应用程序升级到 Angular 10 版本,但在升级后低于警告

WARNING in calendar.reducer.ts depends on lodash/keys. CommonJS or AMD dependencies can cause optimization bailouts.
Run Code Online (Sandbox Code Playgroud)

我已将以下行添加到我的angular.json文件中,但问题未解决

"allowedCommonJsDependencies": ["lodash"]
Run Code Online (Sandbox Code Playgroud)

我该如何解决上述问题。

javascript angular-upgrade angular angular10

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

“字符串”类型上不存在属性“replaceAll”

我想replaceAll在打字稿和角度 10 中使用。

但我收到此错误:属性 'replaceAll' 在类型 'string' 上不存在

这是我的代码:

let date="1399/06/08"
console.log(date.replaceAll('/', '_'))
Run Code Online (Sandbox Code Playgroud)

输出:13990608

如何修复我的打字稿以显示此功能?

typescript angular angular10

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

npm 审计修复 angular 10.0.1 后的错误

我今天运行了这个较旧的 10.0.1 angular 项目,它告诉我它有很多低漏洞和一些高漏洞。所以我运行 npm audit fix 来修复它们。但是现在当我尝试运行它时,它给了我这些错误:

Error: ./src/main.ts  
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getResourceDependencies(...) is not a function or its return value is not iterable
    at getDependencies (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:261:56)
    at C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:374:20
    at analyzingFileEmitter (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:307:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)



Error: ./src/polyfills.ts  
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
TypeError: angularCompiler.getResourceDependencies(...) is not a function or its return value is not iterable
    at getDependencies (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:261:56)
    at C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:374:20
    at analyzingFileEmitter (C:\Web\vgc\vgc\node_modules\@ngtools\webpack\src\ivy\plugin.js:307:20)
    at process._tickCallback (internal/process/next_tick.js:68:7)
Run Code Online (Sandbox Code Playgroud)

任何想法如何解决这一问题?我真的在网上找不到任何相关的问题或解决方案。

angular npm-audit angular10

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

未绑定断点 - VS Code | 铬 | 角

我有一个 Angular 应用程序,我想在VS Code 中调试它。

当我为应用程序提供服务时,例如ng serve断点被绑定并被击中:

在此处输入图片说明

但是,当我通过不同的配置提供服务时,例如,ng serve -c qa或者ng serve -c uat它们变得未绑定:

在此处输入图片说明

是否有断点未绑定的原因?在使用不同的环境配置服务时如何获得断点?


相关信息

launch.json配置:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

angular.json示例环境配置:

"uat": {
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts",
      "with": "src/environments/environment.uat.ts"
    }
  ],
  "optimization": true,
  "outputHashing": "all",
  "sourceMap": false,
  "extractCss": true,
  "namedChunks": false,
  "extractLicenses": false,
  "vendorChunk": false,
  "buildOptimizer": true,
  "budgets": [
    { …
Run Code Online (Sandbox Code Playgroud)

google-chrome visual-studio-code angular vscode-debugger angular10

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

无法加载由 NPM 安装的应用程序(例如文件 C:\Users\name\AppData\Roaming\npm\ng.ps1),因为在此系统上禁用了运行脚本

在运行 npm 安装的命令(即 yarn、ng 等)时,我收到以下错误:

File C:\Users\<username>\AppData\Roaming\npm\<application> cannot be loaded because running scripts is disabled on this system.
Run Code Online (Sandbox Code Playgroud)

其中 <application> 是 npm 安装的命令之一(即 yarn、ng 等)

如何解决这个问题?

npm hadoop-yarn angular angular10

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

o.Subject 不是构造函数 - Angular 10

Ng serveng build --prod命令工作正常,但是当我在服务器上部署应用程序时,出现以下错误:-

TypeError: o.Subject is not a constructor
at new e (vendor-esnext.js:1)
at Object.useFactory (vendor-esnext.js:1)
at Object.i [as factory] (vendor-esnext.js:1)
at Xo.hydrate (vendor-esnext.js:1)
at Xo.get (vendor-esnext.js:1)
at Jf.get (vendor-esnext.js:1)
at Object.get (vendor-esnext.js:1)
at Gn (vendor-esnext.js:1)
at Module.Sl (vendor-esnext.js:1)
at Mn.e.?fac [as factory] (vendor-esnext.js:1)
Run Code Online (Sandbox Code Playgroud)

tsconfig.base.json

{"compilerOptions": {
"baseUrl": "",
"allowSyntheticDefaultImports": true,
"declaration": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
  "dom",
  "es2017"
],
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"target": "ESNext",
"paths": {
  "@angular/*": [ …
Run Code Online (Sandbox Code Playgroud)

rxjs angular angular10

20
推荐指数
1
解决办法
5655
查看次数

resolveJsonModule 在 Angular 10 中不起作用?

我在一个全新的 Angular 10 项目的资产文件夹中有一个基本的 JSON 文件。
Angular CLI:10.0.1 节点:14.5.0 操作系统:win32 x64 TSC 版本 3.9.5。在我的 tsconfig.json 我有

  "compilerOptions": {
    "module": "commonjs",
    "resolveJsonModule": true,
    "esModuleInterop": true
  }
Run Code Online (Sandbox Code Playgroud)

I have restarted vscode multiple times, and tried compiling from the vscode terminal, a powershell window, and a bash terminal, all returning the same message: "Consider using '--resolveJsonModule' to import module with '.json' extension". I have tried compiling with multiple combinations of different options. At this point I'm wondering if I should restart this project …

typescript angular angular10

13
推荐指数
3
解决办法
8205
查看次数

Angular:在 VSCode 中运行 ngcc 会导致性能问题

在上次更新后的 Visual Studio Code 编辑器中,我在状态栏中看到此文本:

在此处输入图片说明

Angular: Running ngcc for project d:/..../tsconfig.spec.json

它看起来像冻结或什么都不做,只是旋转箭头。

在这篇文章之前,我看到了一个类似的tscfonfig.json结尾......

由于此文本显示在状态中,我的 vscode 存在一些性能问题……它变得非常非常缓慢。有时,快速导入(ctrl-space)通常不起作用,找不到类,在此更新之前运行良好的接口。

这是什么?这是必要的还是我可以以某种方式关闭?这可能是插件错误吗?

visual-studio-code angular angular-language-service angular10

13
推荐指数
2
解决办法
3722
查看次数

错误错误:未捕获(承诺):类型错误:i.BehaviorSubject 不是 Angular 10 SSR 中的构造函数

请帮我解决问题:在此处输入图片描述

成功构建并在具有角度通用的浏览器上运行后,我遇到了这个问题

这是我的包 json :

{
  "name": "ssr",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "10.0.5",
    "@angular/cdk": "10.1.0",
    "@angular/common": "10.0.5",
    "@angular/compiler": "10.0.5",
    "@angular/core": "10.0.5",
    "@angular/fire": "^6.0.2",
    "@angular/forms": "10.0.5",
    "@angular/http": "^7.2.16",
    "@angular/localize": "^10.0.5",
    "@angular/material": "10.1.0",
    "@angular/material-moment-adapter": "10.1.0",
    "@angular/platform-browser": "10.0.5",
    "@angular/platform-browser-dynamic": "10.0.5",
    "@angular/platform-server": "^10.0.5",
    "@angular/router": "10.0.5",
    "@ng-bootstrap/ng-bootstrap": "^7.0.0",
    "@ng-toolkit/universal": "^8.1.0",
    "@nguniversal/express-engine": "^10.0.1",
    "@types/jquery": "^3.5.1",
    "@types/node": "^8.10.62",
    "angular-in-memory-web-api": "^0.11.0",
    "angular-ng-autocomplete": "^2.0.1",
    "classlist.js": "^1.1.20150312",
    "codelyzer": "^6.0.0",
    "core-js": "2.6.9",
    "crypto-js": "^3.3.0",
    "express": "^4.15.2",
    "firebase": "^7.17.1",
    "hammerjs": "^2.0.8",
    "jquery": "^3.5.1",
    "localstorage-polyfill": "^1.0.1",
    "moment": "2.24.0",
    "ng2-slim-loading-bar": …
Run Code Online (Sandbox Code Playgroud)

commonjs server-side-rendering angular-universal rxjs6 angular10

12
推荐指数
2
解决办法
4260
查看次数

Angular 10 在 Visual Studio Code 的 HTML 组件中“未找到...的定义”

我正在 VSCode 中使用 Angular 10,直到今天一切都工作正常。突然间,我无法通过 F12、右键单击 - 转到定义或 Ctrl+单击从 HTML 组件转到定义。

转到定义仅适用于打字稿组件,除了“找不到......的定义”之外,我也没有收到任何错误。

我尝试过更新 VS Code、重新安装 VS Code 并重新安装扩展:John Papa 的 Angular Essentials Angular Language Service Angular Snippets

我在所有项目(其中两个)中也经历了相同的行为。

谢谢!

go-to-definition html-components visual-studio-code angular angular10

10
推荐指数
1
解决办法
3514
查看次数