【问题标题】:Getting error after install `single-spa`, not able to understand the issue安装“single-spa”后出现错误,无法理解问题
【发布时间】:2020-05-20 04:09:54
【问题描述】:

在我将 Angular 从 8 升级到 9 后,我实现了 single-spa。当我通过运行命令 yarn serve:single-spa:ibo 开始运行应用程序时出现以下错误。

$ ng s --project ibo --disable-host-check --port 4200 --deploy-url http://localhost:4200/ --live-reload false
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.

To disable this warning use "ng set --global warnings.packageDeprecation=false".

The option '--project' is not registered with the serve command. Run `ng serve --help` for a list of supported options.
The option '--disable-host-check' is not registered with the serve command. Run `ng serve --help` for a list of supported options.
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
    at Class.run (C:\722333\AOS.Setup\Source\UI\node_modules\angular-cli\tasks\serve.js:22:61)
    at C:\722333\AOS.Setup\Source\UI\node_modules\angular-cli\commands\serve.run.js:22:22
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

无法理解问题。有人请帮帮我吗? 这是我的angular.json 文件:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ibo": {
      "root": "src",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "",
      "schematics": {
        "@ngrx/schematics:component:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-builders/custom-webpack:browser",
          "options": {
            "outputPath": "dist/ibo",
            "index": "src/index.html",
            "main": "src\\main.single-spa.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/web.config"
            ],
            "stylePreprocessorOptions": {
              "includePaths": [
                "node_modules/simplebar",
                "node_modules/bootstrap",
                "node_modules/angular-calendar",
                "node_modules/@ibo/shared-lib",
                "src/styles",
                "src/assets/js/datepicker.min.css"
              ]
            },
            "scripts": [
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "src/assets/js/datepicker.min.js"
            ],
            "styles": [
              "./node_modules/@ibo/ibo-shared-lib/styles/styles.scss",
              "./node_modules/quill/dist/quill.core.css",
              "./node_modules/quill/dist/quill.snow.css"
            ],
            "customWebpackConfig": {
              "path": "src\\extra-webpack.config.js"
            }
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "none",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "10mb",
                  "maximumError": "50mb"
                }
              ]
            },
            "insprint": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.insprint.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "none",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false
            },
            "qa": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.qa.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "none",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false
            },
            "sit": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.sit.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "none",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": false
            }
          }
        },
        "serve": {
          "builder": "@angular-builders/custom-webpack:dev-server",
          "options": {
            "browserTarget": "ibo:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "ibo:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "ibo:build"
          }
        },
        "test": {
          "builder": "@angular-builders/jest:run",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "configPath": "./jest.config.js",
            "styles": [],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "ibo-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "prefix": "",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "ibo:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "ibo:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "ibo",
  "cli": {
    "defaultCollection": "@ngrx/schematics"
  }
}

【问题讨论】:

  • 你试过运行 npm install 吗?
  • 我正在使用纱线。您的意思是重新安装吗?
  • 我的意思是重新安装所有本地依赖。
  • 是的,我用 yarn 完成了
  • 提供ng --version的输出

标签: angular single-spa-angular single-spa


【解决方案1】:

ng --version 之后,您应该会看到如下内容

Your global Angular CLI version (10.0.0-next.6) is greater than your local
version (9.1.6). The local Angular CLI version is used.

安装最新稳定的angular/cli as described

这取决于你的旧版本,尝试如下

npm uninstall -g angular-cli
npm uninstall -g @angular/cli
npm install -g @angular/cli@latest 

ng --version 不仅应该给出单行,而且应该如下

Angular CLI: 9.1.6
Node: 10.16.0
OS: win32 x64

Angular: 9.1.7
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.6
@angular-devkit/build-angular     0.901.6
@angular-devkit/build-optimizer   0.901.6
@angular-devkit/build-webpack     0.901.6
@angular-devkit/core              9.1.6
@angular-devkit/schematics        9.1.6
@angular/cli                      9.1.6
@angular/fire                     6.0.0
@ngtools/webpack                  9.1.6
@schematics/angular               9.1.6
@schematics/update                0.901.6
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

【讨论】:

  • 实际上我的项目是用 angular 8 创建的。现在我已经更新到 angular 9。我尝试使用 yarn 重新安装 package.json 几次。
  • @3gwebtrain 我认为这不是纱线问题,您需要在全局中更新 angular/cli
  • 好的。会做并更新你。但是当我也使用 9.x 时,我遇到了这个问题
  • 我发现一条消息为Migration failed: Incompatible peer dependencies found。我可以用--force 安装吗?
  • 是的,如果没有帮助,您可以创建新的测试项目,如“ng new test”,并比较最小角度项目中的哪些库不匹配,之后您需要将旧项目中的必要库添加到新项目中项目以查看应该升级哪个版本
猜你喜欢
  • 2019-11-07
  • 2019-03-25
  • 2018-12-06
  • 1970-01-01
  • 1970-01-01
  • 2012-11-29
  • 2012-08-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多