depngn icon indicating copy to clipboard operation
depngn copied to clipboard

[Feature Request]: support for npm scoped packages

Open garryyao opened this issue 2 years ago • 1 comments

Describe your request

Currently this tool does not support scoped NPM packages which makes it harder to use on repos with such, e.g.

  "dependencies": {
    "@apollo/server": "^4.2.2",
   ...

I'm getting the following error

❯ npx depngn 18.12.0      
npx: installed 22 in 2.283s
Error: TypeError: Cannot read property '@apollo/server' of undefined

Possible Implementation

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

garryyao avatar Mar 15 '23 09:03 garryyao

@garryyao, as far as I know, this package does support scoped packages -- we do manual QA by running depngn on the codebase and we use several packages that are scoped (@types and @rollup off the top of my head).

which version of depngn did you use? does this problem still happen if you run npx depngn@latest?

if it does, my best guess is that package-lock.json is missing or malformed (if using with npm in depngn >=0.4.0) -- more likely that it's malformed somehow, because there is an explicit check for this file existing before we actually try to read from it. does running npm install and then trying depngn again work?

looking through the code, the most likely place for this error to come from is line 42 of src/core/getEngines.ts -- it seems we've missed an optional chain between packages and the computed property key.

If you're using depngn <0.4.0, i'm not really sure yet where this could be coming from.

if none of those things resolve this issue, could you make a repo with a minimal reproduction so we can potentially triage as a bug? because that would mean we're missing error handling somewhere that's letting undefined make it through other checks. thanks!

kindoflew avatar Mar 15 '23 22:03 kindoflew