Skip to content

Bug report: spfx project upgrade: Error: Cannot read property 'length' of undefined #4971

@AJIXuMuK

Description

@AJIXuMuK

Priority

(Medium) I'm annoyed but I'll live

Description

When trying to use m365 spfx project upgrade command I'm getting
Error: Cannot read property 'length' of undefined

Tried node 14 and 18, CLI versions 6.7.0, 6.8.0 and beta - same results.

Updating from 1.15.2

Steps to reproduce

m365 spfx project upgrade with or without args

Expected results

generated set of steps to upgrade the project

Actual results

Error as described above.

Diagnostics

Executing command spfx project upgrade with options {"options":{"output":"md","debug":true}}
Collecting project...
Collected project
{
  path: '/Users/alexterentiev/demos/pnp-controls',
  gitignore: {
    source: '# Logs\n' +
      'logs\n' +
      '*.log\n' +
      'npm-debug.log*\n' +
      '\n' +
      '# Dependency directories\n' +
      'node_modules\n' +
      '\n' +
      '# Build generated files\n' +
      'dist\n' +
      'lib\n' +
      'solution\n' +
      'temp\n' +
      '.heft\n' +
      'release\n' +
      '*.sppkg\n' +
      '\n' +
      '# Coverage directory used by tools like istanbul\n' +
      'coverage\n' +
      '\n' +
      '# OSX\n' +
      '.DS_Store\n' +
      '\n' +
      '# Visual Studio files\n' +
      '.ntvs_analysis.dat\n' +
      '.vs\n' +
      'bin\n' +
      'obj\n' +
      '\n' +
      '# Resx Generated Code\n' +
      '*.resx.ts\n' +
      '\n' +
      '# Styles Generated Code\n' +
      '*.scss.ts\n'
  },
  npmignore: {
    source: '!dist\n' +
      'config\n' +
      '\n' +
      'gulpfile.js\n' +
      '\n' +
      'release\n' +
      'src\n' +
      'temp\n' +
      '\n' +
      'tsconfig.json\n' +
      'tslint.json\n' +
      '\n' +
      '*.log\n' +
      '\n' +
      '.yo-rc.json\n' +
      '.vscode\n'
  },
  configJson: {
    '$schema': 'https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json',
    version: '2.0',
    bundles: { 'pn-p-carousel-web-part': [Object] },
    externals: {},
    localizedResources: {
      PnPCarouselWebPartStrings: 'lib/webparts/pnPCarousel/loc/{locale}.js',
      ControlStrings: 'node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js',
      PropertyControlStrings: 'node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js'
    },
    source: '{\n' +
      '  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",\n' +
      '  "version": "2.0",\n' +
      '  "bundles": {\n' +
      '    "pn-p-carousel-web-part": {\n' +
      '      "components": [\n' +
      '        {\n' +
      '          "entrypoint": "./lib/webparts/pnPCarousel/PnPCarouselWebPart.js",\n' +
      '          "manifest": "./src/webparts/pnPCarousel/PnPCarouselWebPart.manifest.json"\n' +
      '        }\n' +
      '      ]\n' +
      '    }\n' +
      '  },\n' +
      '  "externals": {},\n' +
      '  "localizedResources": {\n' +
      '    "PnPCarouselWebPartStrings": "lib/webparts/pnPCarousel/loc/{locale}.js",\n' +
      '    "ControlStrings": "node_modules/@pnp/spfx-controls-react/lib/loc/{locale}.js",\n' +
      '    "PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js"\n' +
      '  }\n' +
      '}\n'
  },
  deployAzureStorageJson: {
    '$schema': 'https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json',
    workingDir: './release/assets/',
    account: '<!-- STORAGE ACCOUNT NAME -->',
    container: 'pnp-controls',
    accessKey: '<!-- ACCESS KEY -->',
    source: '{\n' +
      '  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",\n' +
      '  "workingDir": "./release/assets/",\n' +
      '  "account": "<!-- STORAGE ACCOUNT NAME -->",\n' +
      '  "container": "pnp-controls",\n' +
      '  "accessKey": "<!-- ACCESS KEY -->"\n' +
      '}\n'
  },
  packageJson: {
    name: 'pnp-controls',
    version: '0.0.1',
    private: true,
    main: 'lib/index.js',
    engines: 'undefined',
    scripts: { build: 'gulp bundle', clean: 'gulp clean', test: 'gulp test' },
    dependencies: {
      '@microsoft/sp-adaptive-card-extension-base': '1.15.2',
      '@microsoft/sp-core-library': '1.15.2',
      '@microsoft/sp-lodash-subset': '1.15.2',
      '@microsoft/sp-office-ui-fabric-core': '1.15.2',
      '@microsoft/sp-property-pane': '1.15.2',
      '@microsoft/sp-webpart-base': '1.15.2',
      '@pnp/spfx-controls-react': '3.10.0',
      '@pnp/spfx-property-controls': '3.9.0',
      'office-ui-fabric-react': '7.185.7',
      react: '16.13.1',
      'react-dom': '16.13.1',
      tslib: '2.3.1'
    },
    devDependencies: {
      '@microsoft/eslint-config-spfx': '1.15.2',
      '@microsoft/eslint-plugin-spfx': '1.15.2',
      '@microsoft/rush-stack-compiler-4.5': '0.2.2',
      '@microsoft/sp-build-web': '1.15.2',
      '@microsoft/sp-module-interfaces': '1.15.2',
      '@microsoft/sp-tslint-rules': '1.11.0',
      '@rushstack/eslint-config': '2.5.1',
      '@types/react': '16.9.51',
      '@types/react-dom': '16.9.8',
      '@types/webpack-env': '1.15.2',
      ajv: '6.12.5',
      eslint: '8.7.0',
      'eslint-plugin-react-hooks': '4.3.0',
      gulp: '4.0.2',
      typescript: '4.5.5'
    },
    source: '{\n' +
      '  "name": "pnp-controls",\n' +
      '  "version": "0.0.1",\n' +
      '  "private": true,\n' +
      '  "main": "lib/index.js",\n' +
      '  "engines": "undefined",\n' +
      '  "scripts": {\n' +
      '    "build": "gulp bundle",\n' +
      '    "clean": "gulp clean",\n' +
      '    "test": "gulp test"\n' +
      '  },\n' +
      '  "dependencies": {\n' +
      '    "@microsoft/sp-adaptive-card-extension-base": "1.15.2",\n' +
      '    "@microsoft/sp-core-library": "1.15.2",\n' +
      '    "@microsoft/sp-lodash-subset": "1.15.2",\n' +
      '    "@microsoft/sp-office-ui-fabric-core": "1.15.2",\n' +
      '    "@microsoft/sp-property-pane": "1.15.2",\n' +
      '    "@microsoft/sp-webpart-base": "1.15.2",\n' +
      '    "@pnp/spfx-controls-react": "3.10.0",\n' +
      '    "@pnp/spfx-property-controls": "3.9.0",\n' +
      '    "office-ui-fabric-react": "7.185.7",\n' +
      '    "react": "16.13.1",\n' +
      '    "react-dom": "16.13.1",\n' +
      '    "tslib": "2.3.1"\n' +
      '  },\n' +
      '  "devDependencies": {\n' +
      '    "@microsoft/eslint-config-spfx": "1.15.2",\n' +
      '    "@microsoft/eslint-plugin-spfx": "1.15.2",\n' +
      '    "@microsoft/rush-stack-compiler-4.5": "0.2.2",\n' +
      '    "@microsoft/sp-build-web": "1.15.2",\n' +
      '    "@microsoft/sp-module-interfaces": "1.15.2",\n' +
      '    "@microsoft/sp-tslint-rules": "1.11.0",\n' +
      '    "@rushstack/eslint-config": "2.5.1",\n' +
      '    "@types/react": "16.9.51",\n' +
      '    "@types/react-dom": "16.9.8",\n' +
      '    "@types/webpack-env": "1.15.2",\n' +
      '    "ajv": "6.12.5",\n' +
      '    "eslint": "8.7.0",\n' +
      '    "eslint-plugin-react-hooks": "4.3.0",\n' +
      '    "gulp": "4.0.2",\n' +
      '    "typescript": "4.5.5"\n' +
      '  }\n' +
      '}\n'
  },
  packageSolutionJson: {
    '$schema': 'https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json',
    solution: {
      name: 'pnp-controls-client-side-solution',
      id: 'd962ac1b-3cbb-44fa-86e5-49d5dcc034ed',
      version: '1.0.0.0',
      includeClientSideAssets: true,
      skipFeatureDeployment: true,
      isDomainIsolated: false,
      developer: [Object],
      metadata: [Object]
    },
    paths: { zippedPackage: 'solution/pnp-controls.sppkg' },
    source: '{\n' +
      '  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",\n' +
      '  "solution": {\n' +
      '    "name": "pnp-controls-client-side-solution",\n' +
      '    "id": "d962ac1b-3cbb-44fa-86e5-49d5dcc034ed",\n' +
      '    "version": "1.0.0.0",\n' +
      '    "includeClientSideAssets": true,\n' +
      '    "skipFeatureDeployment": true,\n' +
      '    "isDomainIsolated": false,\n' +
      '    "developer": {\n' +
      '      "name": "",\n' +
      '      "websiteUrl": "",\n' +
      '      "privacyUrl": "",\n' +
      '      "termsOfUseUrl": "",\n' +
      '      "mpnId": ""\n' +
      '    },\n' +
      '    "metadata": {\n' +
      '      "shortDescription": {\n' +
      '        "default": "pnp-controls description"\n' +
      '      },\n' +
      '      "longDescription": {\n' +
      '        "default": "pnp-controls description"\n' +
      '      },\n' +
      '      "screenshotPaths": [],\n' +
      '      "videoUrl": "",\n' +
      '      "categories": []\n' +
      '    }\n' +
      '  },\n' +
      '  "paths": {\n' +
      '    "zippedPackage": "solution/pnp-controls.sppkg"\n' +
      '  }\n' +
      '}\n'
  },
  serveJson: {
    '$schema': 'https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json',
    port: 4321,
    https: true,
    initialPage: 'https://enter-your-SharePoint-site/_layouts/workbench.aspx',
    source: '{\n' +
      '  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",\n' +
      '  "port": 4321,\n' +
      '  "https": true,\n' +
      '  "initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"\n' +
      '}\n'
  },
  tsConfigJson: {
    extends: './node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json',
    compilerOptions: {
      target: 'es5',
      forceConsistentCasingInFileNames: true,
      module: 'esnext',
      moduleResolution: 'node',
      jsx: 'react',
      declaration: true,
      sourceMap: true,
      experimentalDecorators: true,
      skipLibCheck: true,
      outDir: 'lib',
      inlineSources: false,
      strictNullChecks: false,
      noUnusedLocals: false,
      noImplicitAny: true,
      typeRoots: [Array],
      types: [Array],
      lib: [Array]
    },
    include: [ 'src/**/*.ts', 'src/**/*.tsx' ],
    exclude: [],
    source: '{\n' +
      '  "extends": "./node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json",\n' +
      '  "compilerOptions": {\n' +
      '    "target": "es5",\n' +
      '    "forceConsistentCasingInFileNames": true,\n' +
      '    "module": "esnext",\n' +
      '    "moduleResolution": "node",\n' +
      '    "jsx": "react",\n' +
      '    "declaration": true,\n' +
      '    "sourceMap": true,\n' +
      '    "experimentalDecorators": true,\n' +
      '    "skipLibCheck": true,\n' +
      '    "outDir": "lib",\n' +
      '    "inlineSources": false,\n' +
      '    "strictNullChecks": false,\n' +
      '    "noUnusedLocals": false,\n' +
      '    "noImplicitAny": true,\n' +
      '    "typeRoots": [\n' +
      '      "./node_modules/@types",\n' +
      '      "./node_modules/@microsoft"\n' +
      '    ],\n' +
      '    "types": [\n' +
      '      "webpack-env"\n' +
      '    ],\n' +
      '    "lib": [\n' +
      '      "es5",\n' +
      '      "dom",\n' +
      '      "es2015.collection",\n' +
      '      "es2015.promise"\n' +
      '    ]\n' +
      '  },\n' +
      '  "include": [\n' +
      '    "src/**/*.ts",\n' +
      '    "src/**/*.tsx"\n' +
      '  ],\n' +
      '  "exclude": []\n' +
      '}\n'
  },
  writeManifestsJson: {
    '$schema': 'https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json',
    cdnBasePath: '<!-- PATH TO CDN -->',
    source: '{\r\n' +
      '  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",\r\n' +
      '  "cdnBasePath": "<!-- PATH TO CDN -->"\r\n' +
      '}'
  },
  yoRcJson: {
    '@microsoft/generator-sharepoint': {
      packageManager: 'yarn',
      isCreatingSolution: true,
      environment: 'spo',
      version: '1.15.2',
      libraryName: 'pnp-controls',
      libraryId: 'd962ac1b-3cbb-44fa-86e5-49d5dcc034ed',
      isDomainIsolated: false,
      componentType: 'webpart'
    },
    source: '{\n' +
      '  "@microsoft/generator-sharepoint": {\n' +
      '    "packageManager": "yarn",\n' +
      '    "isCreatingSolution": true,\n' +
      '    "environment": "spo",\n' +
      '    "version": "1.15.2",\n' +
      '    "libraryName": "pnp-controls",\n' +
      '    "libraryId": "d962ac1b-3cbb-44fa-86e5-49d5dcc034ed",\n' +
      '    "isDomainIsolated": false,\n' +
      '    "componentType": "webpart"\n' +
      '  }\n' +
      '}\n'
  },
  gulpfileJs: {
    source: "'use strict';\n" +
      '\n' +
      "const build = require('@microsoft/sp-build-web');\n" +
      '\n' +
      "build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);\n" +
      '\n' +
      'var getTasks = build.rig.getTasks;\n' +
      'build.rig.getTasks = function () {\n' +
      '  var result = getTasks.call(build.rig);\n' +
      '\n' +
      "  result.set('serve', result.get('serve-deprecated'));\n" +
      '\n' +
      '  return result;\n' +
      '};\n' +
      '\n' +
      "build.initialize(require('gulp'));\n"
  },
  esLintRcJs: TsFile {
    path: '/Users/alexterentiev/demos/pnp-controls/.eslintrc.js'
  },
  vsCode: {
    settingsJson: {
      'files.exclude': [Object],
      'typescript.tsdk': '.\\node_modules\\typescript\\lib',
      source: '                                                                           \r\n' +
        '{\r\n' +
        '                                                                                  \r\n' +
        '  "files.exclude": {\r\n' +
        '    "**/.git": true,\r\n' +
        '    "**/.DS_Store": true,\r\n' +
        '    "**/bower_components": true,\r\n' +
        '    "**/coverage": true,\r\n' +
        '    "**/lib-amd": true,\r\n' +
        '    "src/**/*.scss.ts": true\r\n' +
        '  },\r\n' +
        '  "typescript.tsdk": ".\\\\node_modules\\\\typescript\\\\lib"\r\n' +
        '}'
    },
    extensionsJson: {
      recommendations: [Array],
      source: '{\r\n  "recommendations": [\r\n    "msjsdiag.debugger-for-chrome"\r\n  ]\r\n}'
    },
    launchJson: {
      version: '0.2.0',
      configurations: [Array],
      source: '{\n' +
        '     \n' +
        '                                                                                               \n' +
        '                                                            \n' +
        '     \n' +
        '  "version": "0.2.0",\n' +
        '  "configurations": [{\n' +
        '    "type": "pwa-chrome"\n' +
        '  },\n' +
        '    {\n' +
        '      "name": "Hosted workbench",\n' +
        '      "type": "chrome",\n' +
        '      "request": "launch",\n' +
        '      "url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",\n' +
        '      "webRoot": "${workspaceRoot}",\n' +
        '      "sourceMaps": true,\n' +
        '      "sourceMapPathOverrides": {\n' +
        '        "webpack:///.././src/*": "${webRoot}/src/*",\n' +
        '        "webpack:///../../../src/*": "${webRoot}/src/*",\n' +
        '        "webpack:///../../../../src/*": "${webRoot}/src/*",\n' +
        '        "webpack:///../../../../../src/*": "${webRoot}/src/*"\n' +
        '      },\n' +
        '      "runtimeArgs": [\n' +
        '        "--remote-debugging-port=9222",\n' +
        '        "-incognito"\n' +
        '      ]\n' +
        '    }\n' +
        '  ]\n' +
        '}\n'
    }
  },
  manifests: [
    {
      '$schema': 'https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json',
      id: 'cfa7b134-271f-4d61-8225-706db73666c3',
      alias: 'PnPCarouselWebPart',
      componentType: 'WebPart',
      version: '*',
      manifestVersion: 2,
      requiresCustomScript: false,
      supportedHosts: [Array],
      preconfiguredEntries: [Array],
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/PnPCarouselWebPart.manifest.json',
      source: '{\r\n' +
        '  "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",\r\n' +
        '  "id": "cfa7b134-271f-4d61-8225-706db73666c3",\r\n' +
        '  "alias": "PnPCarouselWebPart",\r\n' +
        '  "componentType": "WebPart",\r\n' +
        '\r\n' +
        '                                                                             \r\n' +
        '  "version": "*",\r\n' +
        '  "manifestVersion": 2,\r\n' +
        '\r\n' +
        '                                                                                          \r\n' +
        '                                                                                          \r\n' +
        '                                                                                                                        \r\n' +
        '  "requiresCustomScript": false,\r\n' +
        '  "supportedHosts": ["SharePointWebPart"],\r\n' +
        '\r\n' +
        '  "preconfiguredEntries": [{\r\n' +
        '    "groupId": "5c03119e-3074-46fd-976b-c60198311f70",         \r\n' +
        '    "group": { "default": "Other" },\r\n' +
        '    "title": { "default": "PnP Carousel" },\r\n' +
        '    "description": { "default": "PnP Carousel description" },\r\n' +
        '    "officeFabricIconFontName": "Page",\r\n' +
        '    "properties": {\r\n' +
        '      "description": "PnP Carousel"\r\n' +
        '    }\r\n' +
        '  }]\r\n' +
        '}\r\n'
    }
  ],
  tsFiles: [
    TsFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/index.ts'
    },
    TsFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/PnPCarouselWebPart.ts'
    },
    TsFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/components/IPnPCarouselProps.ts'
    },
    TsFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/components/PnPCarousel.module.scss.ts'
    },
    TsFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/components/PnPCarousel.tsx'
    },
    TsFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/loc/mystrings.d.ts'
    }
  ],
  scssFiles: [
    ScssFile {
      path: '/Users/alexterentiev/demos/pnp-controls/src/webparts/pnPCarousel/components/PnPCarousel.module.scss'
    }
  ]
}
Error: Cannot read properties of undefined (reading 'length')

CLI for Microsoft 365 version

6.8.0, 6.7.0, @beta

nodejs version

16.19.0, 14.18.3

Operating system (environment)

macOS

Shell

zsh

cli doctor

{
  "os": {
    "platform": "darwin",
    "version": "Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000",
    "release": "22.5.0"
  },
  "cliVersion": "6.7.0",
  "nodeVersion": "v16.19.0",
  "cliAadAppId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
  "cliAadAppTenant": "common",
  "authMode": "DeviceCode",
  "cliEnvironment": "",
  "cliConfig": {},
  "roles": [],
  "scopes": [
    "AllSites.FullControl",
    "Directory.AccessAsUser.All",
    "openid",
    "profile",
    "TermStore.ReadWrite.All",
    "User.ReadWrite.All",
    "email",
    "AllSites.FullControl",
    "AppCatalog.ReadWrite.All",
    "AuditLog.Read.All",
    "Bookings.Read.All",
    "ChannelMember.ReadWrite.All",
    "ChannelMessage.Read.All",
    "ChannelMessage.Send",
    "ChannelSettings.ReadWrite.All",
    "Chat.Read",
    "Chat.ReadWrite",
    "Directory.AccessAsUser.All",
    "Directory.ReadWrite.All",
    "ExternalConnection.ReadWrite.All",
    "Group.ReadWrite.All",
    "IdentityProvider.ReadWrite.All",
    "Mail.Read.Shared",
    "Mail.ReadWrite",
    "Mail.Send",
    "Notes.Read.All",
    "Place.Read.All",
    "Policy.Read.All",
    "RecordsManagement.ReadWrite.All",
    "Reports.Read.All",
    "SecurityEvents.Read.All",
    "ServiceHealth.Read.All",
    "ServiceMessage.Read.All",
    "ServiceMessageViewpoint.Write",
    "Tasks.ReadWrite",
    "Team.Create",
    "TeamMember.ReadWrite.All",
    "TeamsAppInstallation.ReadWriteForUser",
    "TeamSettings.ReadWrite.All",
    "TeamsTab.ReadWrite.All",
    "TermStore.ReadWrite.All",
    "User.Invite.All",
    "User.ReadWrite.All"
  ]
}

Additional Info

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions