pnpm: ERROR  Cannot read property 'optionalDependencies' of undefined

$ pnpm update -i

Scope: current workspace package
 ERROR  Cannot read property 'optionalDependencies' of undefined
at 0/lib/node_modules/pnpm/…  pnpm/outdated/lib/outdated.js:24
at map
at outdated [as default]      ../../../../../../../nvm/versions/node/v13.5.0/lib/node_modules/pnpm/lib/node_modules/@pnpm/outdated/lib/outdated.js:21                           await Promise.all(types_…
at 0/lib/node_modules/pnpm/…  pnpm/outdated/lib/outdatedDepsOfProjects.js:33
at map
at outdatedDepsOfProjects     ../../../../../../../nvm/versions/node/v13.5.0/lib/node_modules/pnpm/lib/node_modules/@pnpm/outdated/lib/outdatedDepsOfProjects.js:31             return Promise.all(pkgs.…
at async interactiveUpdate    ../../../../../../../nvm/versions/node/v13.5.0/lib/node_modules/pnpm/lib/node_modules/@pnpm/plugin-commands-installation/lib/update/index.js:153  const outdatedPkgsOfProj…

pnpm version: 4.9.0

Additional information:

  • node -v prints: 13.5.0
  • Windows, OS X, or Linux?: macOS

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 6
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I’m running into the same problem after renaming a subdirectory in the workspace.

Environment

  • Windows 20H2
  • Node 15.5.0
  • npm 7.3.0
  • pnpm 5.14.1

Steps to Reproduce

  1. Create these files:

    • /pnpm-workspace.yaml: empty file

    • /package.json

      {
        "name": "@pnpm2313/root",
        "private": true,
        "dependencies": {
          "is-stream": "^2.0.0"
        }
      }
      
    • /a/package.json

      {
        "name": "@pnpm2313/a",
        "private": true,
        "dependencies": {
          "retry": "^0.12.0"
        }
      }
      
  2. Execute pnpm install. This would generate a pnpm-lock.yaml file.

  3. Rename /a directory to /b directory.

    $ mv a b
    
  4. Execute pnpm m outdated.

Error Message

$ pnpm m outdated
 ERROR  Cannot read property 'optionalDependencies' of undefined
at                         ../../../../ProgramData/nvm/v15.5.0/node_modules/pnpm/dist/pnpm.js:98324   if (((_a2 = opts.include…
at map

at outdated [as default]   ../../../../ProgramData/nvm/v15.5.0/node_modules/pnpm/dist/pnpm.js:98322   await Promise.all(types_…
at                         ../../../../ProgramData/nvm/v15.5.0/node_modules/pnpm/dist/pnpm.js:98432   return outdated_1.defaul…
at map

at outdatedDepsOfProjects  ../../../../ProgramData/nvm/v15.5.0/node_modules/pnpm/dist/pnpm.js:98430   return Promise.all(pkgs.…
at default                 ../../../../ProgramData/nvm/v15.5.0/node_modules/pnpm/dist/pnpm.js:100244  const outdatedPackagesBy…
at _onTimeout              ../../../../ProgramData/nvm/v15.5.0/node_modules/pnpm/dist/pnpm.js:122764  result = await result;

Workspace Archive

This is an archive of the folder at the end of step 3: pnpm2313.tar.gz

Known Workaround

Delete pnpm-lock.yaml file and run pnpm install again.

This is now also happening with pnpm outdated -r on some but not all repos.

Screenshot 2024-08-03 at 8 47 04 PM

pnpm version 9.6.0