Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

411
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda