Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!