Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm install <localFolder> removes bundledDependency #7281

Open
2 tasks done
vladiulianbogdan opened this issue Mar 11, 2024 · 3 comments
Open
2 tasks done

[BUG] npm install <localFolder> removes bundledDependency #7281

vladiulianbogdan opened this issue Mar 11, 2024 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@vladiulianbogdan
Copy link

vladiulianbogdan commented Mar 11, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

I have a module defined in a folder. It has it own package.json and a node_modules folder that contains other-lib dependency. The other-lib dependency is not pushed in any registry.

{
  "name": "my-lib",
  "version": "1.0.0",
  "bundleDependencies": [
    "other-lib"
  ],
  "description": "",
  "main": "./lib/index.js",
  "dependencies": {
    "other-lib": "1.0.0"
  }
}

If I install my-lib from the folder with npm install ./my-lib-folder in an existing project, the node_module/other-lib folder is removed.

Expected Behavior

The node_modules folder from the module my-lib should not be removed. If i run npm pack in the my-lib folder, the node_modules/other-lib folder is kept. Also, if I push my-lib to a registry and I install it via npm install the node_modules/other-lib folder is still present.

Steps To Reproduce

See comment below.

Environment

  • npm: 10.5
  • Node.js: v18.18.1
  • OS Name: OS Ventura
@vladiulianbogdan vladiulianbogdan added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Mar 11, 2024
@milaninfy
Copy link
Contributor

@vladiulianbogdan I tried to reproduce based on given issue description, but i was unable reproduce. Please include steps to reproduce.

@milaninfy milaninfy added Awaiting Information further information is requested and removed Needs Triage needs review for next steps labels Mar 15, 2024
@vladiulianbogdan
Copy link
Author

I've attached the following zip:

client-ts.zip

In the ./sdk folder you can see a dependency that has a bundled dependency "genezio-remote".

Steps to reproduce:

  1. Run npm install ./sdk. This will produce the first weird behaviour since it creates a symlink to my folder. This is against what I understand from the npm documentation:

npm install <folder>:

If <folder> sits inside the root of your project, its dependencies will be installed and may be hoisted to the top-level node_modules as they would for other types of dependencies. If <folder> sits outside the root of your project, npm will not install the package dependencies in the directory <folder>, but it will create a symlink to <folder>.

(source)

  1. If you run one more npm install you will see the following output.
iulian-bogdanvlad@Iulian-Bogdans-MacBook-Pro client-ts 2 % npm install

removed 1 package, and audited 263 packages in 3s

Now the bundled dependency has disappeared (you can check with ls node_modules/qweqweq/node_modules).

@milaninfy milaninfy added Needs Triage needs review for next steps and removed Awaiting Information further information is requested labels Apr 1, 2024
@milaninfy
Copy link
Contributor

milaninfy commented Apr 10, 2024

@vladiulianbogdan If you need to change symlink behaviour, you can try enable this flag https://docs.npmjs.com/cli/v10/using-npm/config#install-links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

3 participants