Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
Is it possible to use npm dependencies from another package in my own project?

I have a node.js project. In this project I have dependency A, and dependency B, also I noticed that dependency A inside it's dependencies has dependency B, so my question is should I install dependency B or I can just use it from dependency A ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can, but...

What happens if dependency A no longer has the dependency on B?

For this reason, you should add as dependencies all packages you require in your code.

Edit

Further points to consider:

Your code has been build for version 1.0.0 of the code, and A has upgraded the version of B required to 2.0.0 of the code.

Assuming dependency B follows SEMVER, major breaking changes will have occured between version 1.0.0 and version 2.0.0. If B doesn't follow SEMVER, then breaking changes could apply at any moment.

NPM (Yarn, and other package managers) will take care of this, and provide the correct version for the different packages and the project as a whole. This means version 1.0.0 of package B will be put directly in your node_modules folder, whilst version 2.0.0 of package B is put into the node_modules folder for package A.

Frameworks/Libraries

When including a library, framework, or the likes, it is common to use packages that library/framework use directly even though you haven't put them in your references.

This should be kept to a minimum, and only according to the library/framework documentation as it can cause complications if you ever need to upgrade the library/framework (which you should do frequently).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda