Skip to content

× Migration failed: Cannot convert undefined or null to object #26337

Closed

Description

@kibetmasi

Command

update

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Trying to update an Angular project (library and schematics) to angular V17 using the command ng update.
However, I'm receiving the error below:

Using package manager: npm
Collecting installed dependencies...
Found 26 dependencies.
× Migration failed: Cannot convert undefined or null to object
  See "C:\Users\Mercy\AppData\Local\Temp\ng-RsET9k\angular-errors.log" for further details.

Minimal Reproduction

Root package.json file:

{
    "name": "pv2",
    "version": "0.0.0",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "watch": "ng build --watch --configuration development",
        "test": "ng test"
    },
    "private": true,
    "dependencies": {
        "@angular-devkit/schematics": "^16.2.9",
        "@angular/animations": "^16.0.0",
        "@angular/common": "^16.0.0",
        "@angular/compiler": "^16.0.0",
        "@angular/core": "^16.0.0",
        "@angular/forms": "^16.0.0",
        "@angular/platform-browser": "^16.0.0",
        "@angular/platform-browser-dynamic": "^16.0.0",
        "@angular/router": "^16.0.0",
        "pesapalschema": "^0.0.5",
        "rxjs": "~7.8.0",
        "zone.js": "~0.13.0"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "^16.0.1",
        "@angular/cli": "~16.2.9",
        "@angular/compiler-cli": "^16.0.0",
        "@types/jasmine": "~4.3.0",
        "copyfiles": "^2.4.1",
        "jasmine-core": "~4.6.0",
        "karma": "~6.4.0",
        "karma-chrome-launcher": "~3.2.0",
        "karma-coverage": "~2.2.0",
        "karma-jasmine": "~5.1.0",
        "karma-jasmine-html-reporter": "~2.0.0",
        "ng-packagr": "^16.0.0",
        "tslib": "^2.6.2",
        "typescript": "~5.0.2"
    }
}

angular.json file:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "pv2": {
            "projectType": "application",
            "schematics": {
                "@schematics/angular:component": {
                    "style": "scss"
                }
            },
            "root": "",
            "sourceRoot": "src",
            "prefix": "app",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "dist/pv2",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "polyfills": [
                            "zone.js"
                        ],
                        "tsConfig": "tsconfig.app.json",
                        "inlineStyleLanguage": "scss",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ],
                        "styles": [
                            "src/styles.scss"
                        ],
                        "scripts": []
                    },
                    "configurations": {
                        "production": {
                            "budgets": [{
                                    "type": "initial",
                                    "maximumWarning": "500kb",
                                    "maximumError": "1mb"
                                },
                                {
                                    "type": "anyComponentStyle",
                                    "maximumWarning": "2kb",
                                    "maximumError": "4kb"
                                }
                            ],
                            "outputHashing": "all"
                        },
                        "development": {
                            "buildOptimizer": false,
                            "optimization": false,
                            "vendorChunk": true,
                            "extractLicenses": false,
                            "sourceMap": true,
                            "namedChunks": true
                        }
                    },
                    "defaultConfiguration": "production"
                },
                "serve": {
                    "builder": "@angular-devkit/build-angular:dev-server",
                    "configurations": {
                        "production": {
                            "browserTarget": "pv2:build:production"
                        },
                        "development": {
                            "browserTarget": "pv2:build:development"
                        }
                    },
                    "defaultConfiguration": "development"
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "pv2:build"
                    }
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "polyfills": [
                            "zone.js",
                            "zone.js/testing"
                        ],
                        "tsConfig": "tsconfig.spec.json",
                        "inlineStyleLanguage": "scss",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets"
                        ],
                        "styles": [
                            "src/styles.scss"
                        ],
                        "scripts": []
                    }
                }
            }
        },
        "pesapal": {
            "projectType": "library",
            "root": "projects/pesapal",
            "sourceRoot": "projects/pesapal/src",
            "prefix": "lib",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:ng-packagr",
                    "options": {
                        "project": "projects/pesapal/ng-package.json"
                    },
                    "configurations": {
                        "production": {
                            "tsConfig": "projects/pesapal/tsconfig.lib.prod.json"
                        },
                        "development": {
                            "tsConfig": "projects/pesapal/tsconfig.lib.json"
                        }
                    },
                    "defaultConfiguration": "production"
                },
                "test": {
                    "builder": "@angular-devkit/build-angular:karma",
                    "options": {
                        "tsConfig": "projects/pesapal/tsconfig.spec.json",
                        "polyfills": [
                            "zone.js",
                            "zone.js/testing"
                        ]
                    }
                }
            }
        }
    }
}

tsconfig.json file:

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "paths": {
      "pesapal": [
        "dist/pesapal"
      ]
    },
    "target": "ES2022",
    "module": "ES2022",
    "useDefineForClassFields": false,
    "lib": [
      "ES2022",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

Exception or Error

[error] TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at _buildPackageInfo (C:\Users\Mercy\OneDrive\Desktop\projects\pv2\node_modules\@angular\cli\src\commands\update\schematic\index.js:433:52)
    at C:\Users\Mercy\OneDrive\Desktop\projects\pv2\node_modules\@angular\cli\src\commands\update\schematic\index.js:707:53
    at Map.forEach (<anonymous>)
    at C:\Users\Mercy\OneDrive\Desktop\projects\pv2\node_modules\@angular\cli\src\commands\update\schematic\index.js:706:27
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async callRuleAsync (C:\Users\Mercy\OneDrive\Desktop\projects\pv2\node_modules\@angular-devkit\schematics\src\rules\call.js:77:18)

Your Environment

Angular CLI: 16.2.9
Node: 18.16.0
Package Manager: npm 9.6.6
OS: win32 x64

Angular: 16.2.11
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.9
@angular-devkit/build-angular   16.2.9
@angular-devkit/core            16.2.9
@angular-devkit/schematics      16.2.9
@angular/cli                    16.2.9
@schematics/angular             16.2.9
ng-packagr                      16.2.3
rxjs                            7.8.1
typescript                      5.0.4
zone.js                         0.13.3

Anything else relevant?

Package Manager used: npm

Activity

  1. added
    needs: more info
    needs: investigation
    and removed
    needs: more info
    on Nov 13, 2023
  2. alan-agius4 commented on Nov 15, 2023

    @alan-agius4
    Collaborator

    The problem seems to happen as pesapalschema is a private package. Are you using an NPM RC to config NPM to use a private registry?

  3. kibetmasi commented on Nov 15, 2023

    @kibetmasi
    Author

    I'm not currently using a private registry or an NPM RC file in my project

  4. kibetmasi commented on Nov 15, 2023

    @kibetmasi
    Author

    is there anything else you'd like me to provide information on? I can share my repo if necessary, currently it's private

  5. alan-agius4 commented on Nov 15, 2023

    @alan-agius4
    Collaborator

    So how are you installing pesapalschema which is not in the public NPM registry?

  6. KibetMasiror commented on Nov 15, 2023

    @KibetMasiror
  7. added 3 commits that reference this issue on Nov 15, 2023
    5864c26
    946e3ad
    22e60ae
  8. added 2 commits that reference this issue on Nov 15, 2023
    bec9458
    5267e60
  9. angular-automatic-lock-bot commented on Dec 16, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular/clineeds: investigationng update DX

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions