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: https://github.com/caub/create-react-app/tree/eslint/packages/react-scripts
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://email@example.com/caub/create-react-app/tree/eslint/packages/react-scripts#eslint
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: https://github.com/npm/npm/issues/2974#issuecomment-351118123 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: https://github.com/caub/create-react-app/blob/master/packages/react-scripts/package.json#L8
My question is how could I install it from its github link, not from npm? It’s a pending PR, not merged yet