'Can you skip some dependencies when installing an npm package from a git repository?

I'm currently working with 2 private react projects, both using a single private component library which gets installed from git ("library": "git+ssh://git...#commitref").

The component library has a lot of additional devDependencies, most of which are not related to building the library at all. The component library's devDependencies in package.json includes stuff like typescript, jest, testing-library and storybook, however to successfully build this package only typescript and type declarations are needed. (It is built simply by running tsc -d.) Regardless of this fact, everything else included in devDependencies gets installed, which can slow things down quite a bit.

Is there some way, when installing an npm package from a git repository, to skip installing some of it's dependencies? Such as being able to have npm recognize the difference between build-time requirements and other devDependencies? I have already tried moving heavier stuff - like storybook - into optionalDependencies, but those got installed anyway.

EDIT: Im thinking about moving non-buildtime devDependencies into peerDependencies, marking them as optional and running 'npx npm-install-peers' when developing on the component library, I do hope there is a better aproach to this issue.



Solution 1:[1]

You can use npm install --production, but it will ignore all devDependencies

Solution 2:[2]

This worked for me npm install --force

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pavlo Naumenko
Solution 2 Marshall Divine