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

395
Visualizações
Why npm install <folder> install different dependencies than npm install lib

I have a project1 that already depends on styled-components@4.4.1

When I try to install the project2 as a lib in the project1 using npm install /my/project2/build, my package-lock.json is changed as the snipped showed bellow:

+    "projec2": {
+      "version": "file:/my/project2/build",
+      "requires": {
+        "styled-components": "4.4.1"
+      },
+      "dependencies": {1
+        "@babel/code-frame": {
+          "version": "7.16.7",
           ...
+          "requires": {
+            "@babel/highlight": "^7.16.7"
+          }
+        },
+        "@babel/generator": {
+          "version": "7.17.7",
           ...
+          "requires": {
+            "@babel/types": "^7.17.0",
+            "jsesc": "^2.5.1",
+            "source-map": "^0.5.0"
+          }
+        },
+        "@babel/helper-annotate-as-pure": {
+          "version": "7.16.7",
           ...
+          "requires": {
+            "@babel/types": "^7.16.7"
+          }

But if i publish the same project2 lib and I install it using npm install project2@0.0.1, the package-json.lock on project1 does not show the same requirements:

+    "project2": {
+      "version": "0.0.1",
       ...
+      "requires": {
+        "styled-components": "4.4.1"
+      }
+    },

I would like to make the local folder installation as same as the lib installation, without those third part dependencies.

Update:

I still have the problem installing with npm install <folder> but using npm pack combined with npm install <tarballfile> works like installing the the remote lib. I just dont know why...

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

0

To simulate remote lib installation locally I like to use yalc. You don't necessarily need to install it, you can run with "npx yalc publish" for example.

What "npx yalc publish" does is instead of publishing the build in npm, it will publish it in a local folder. Then when you "npx yalc add project2@0.0.1" it will act as if the lib was downloaded from npm.

It should behave the same as publishing in unkpg and then installing it.

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