zkat / npx

execute npm package binaries (moved)

Home Page:https://github.com/npm/npx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Load already installed peer dependencies

chrisguttandin opened this issue · comments

I'm not sure if that is a bug report, a feature request or a stupid idea.

I noticed that npx does not load peer dependencies if the package that is requested via npx has any. I noticed this today while I triaged a bug (chrisguttandin/angular-prerender#25) for one of my packages. It is a little command line tool which is meant to run in a directory which contains an Angular app. Therefore it assumes @angular/core and some other related packages to be installed anyway and defines them as peer dependencies.

When someone now executes the command line tool via npx it can't find the peer dependencies. I came up with a solution (https://github.com/chrisguttandin/angular-prerender/blob/master/src/functions/load-peer-dependencies.ts) but it feels very hacky.

I would therefore like to propose that npx loads peer dependencies from the directory it currently runs in. But it is absolutely possible that I just found an edge case and it makes not much sense to do this for all packages. What do you think?