npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

How to install a subdirectory as package?

I’d like to install a subdirectory of a git repo:

For example I’d like to do:

npm i -D github:caub/create-react-app/tree/eslint/packages/react-scripts#eslint
# or the equivalent:
npm i -D git+ssh://

It’s not working, but this is a git issue, not an npm issue

npm ERR!   fatal: remote error: 
npm ERR!      caub/create-react-app/tree/eslint/packages/react-scripts is not a valid repository name

I’ve seen: that suggests a feature like

npm i -D github:caub/create-react-app#eslint?path=packages/react-scripts

Does something like that already work? It’s necessary to have this feature

You can do this with npm packages, not sure about git links:

Thanks @shadowspawn, the package has this directory field set up:

My question is how could I install it from its github link, not from npm? It’s a pending PR, not merged yet