cli icon indicating copy to clipboard operation
cli copied to clipboard

fix: Cannot read properties of undefined (reading 'description')

Open vrubezhny opened this issue 3 years ago • 4 comments

A check for not defined node.package value is added to getHumanOutputItem

References

Fixes: #5961

vrubezhny avatar Dec 13 '22 20:12 vrubezhny

I don't think this is a problem we should just if-statement around. If node doesn't have a package attribute either it's an underlying bug, or it's a node type we're not properly handling.

wraithgar avatar Dec 14 '22 15:12 wraithgar

The problem happens with optional/week dependencies that aren't really installed, f.i., for the [email protected] dependency from the issue - it optionally depends on:

  "peerDependencies": {
    "bufferutil": "^4.0.1",
    "utf-8-validate": "^5.0.2"
  },

these modules are not installed by default when using npm install --no-bin-links --ignore-script command. As such, a reference to these modules exist (from ws module's package-lock.json), but no bufferutil/utf-8-validate package.json/package-lock.json files available. to make it possible to read a description or other information for these modules.

vrubezhny avatar Dec 15 '22 11:12 vrubezhny

This can happen even if packages are installed "normally" (i.e. using npm install without any options), if an optional dependency doesn't exist or isn't supported.

For example, try npm install rollup, then npm ll rollup.
(It fails on most platforms because rollup has an optional dependency on fsevents, which is only available for macOS.)

12Me21 avatar Dec 16 '22 22:12 12Me21

I don't think this is a problem we should just if-statement around. If node doesn't have a package attribute either it's an underlying bug, or it's a node type we're not properly handling.

@wraithgar this is indeed a problem, at least for anyone running "npm ls --long" as it is failing in numerous cases. While I don't have a clue on the root-cause of the problem it should at least be clearified when an where "npm ls --long" breaks und how one can get around it if this patch/pr is not the properly adressing the issue.

pniederlag avatar Aug 15 '23 09:08 pniederlag