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](arborist) should not remove global node_modules #4274

Closed
mingc00 opened this issue Oct 4, 2021 · 7 comments
Closed

[BUG](arborist) should not remove global node_modules #4274

mingc00 opened this issue Oct 4, 2021 · 7 comments
Labels
Needs Triage needs review for next steps ws:arborist Related to the arborist workspace

Comments

@mingc00
Copy link

mingc00 commented Oct 4, 2021

What / Why

For switching different Node.js version, we use symlink for global node_modules.

$ ls -ld /usr/local/lib/node_modules
/usr/local/lib/node_modules -> /var/packages/Node.js_v16/var/node_modules

The global module directory and npm itself is removed after installing global module.

$ npm install -g pino-pretty
npm WARN reify Removing non-directory /usr/local/lib/node_modules

The behavior have been changed from npm/arborist@f2b0cee.

How

Current Behavior

$ npm install -g pino-pretty
npm WARN reify Removing non-directory /usr/local/lib/node_modules

Steps to Reproduce

  1. Make global node_modules be symlink.
  2. Run npm install -g <any module>
  3. The global node_modules is removed.

Expected Behavior

Allow global node_modules be symlink.

@ljharb
Copy link
Contributor

ljharb commented Oct 4, 2021

Global modules must not be shared between node versions, for a number of reasons, including that they might be compiled.

@mingc00
Copy link
Author

mingc00 commented Oct 4, 2021

My global node_modules are not shared between node versions.

After switching Node.js version, the node_modules points to different path. That's why our global node_modules is symlink.

@ljharb
Copy link
Contributor

ljharb commented Oct 4, 2021

Typically the way this is done with a node version manager is to move the node_modules folder in its entirety, not with a symlink, or to locate it somewhere else. See nvm, nave, and n for the most common node version managers.

@fritzy fritzy transferred this issue from npm/arborist Jan 20, 2022
@fritzy fritzy changed the title [BUG] should not remove global node_modules [BUG](arborist) should not remove global node_modules Jan 20, 2022
@fritzy fritzy added Needs Triage needs review for next steps ws:arborist Related to the arborist workspace labels Jan 20, 2022
@tophf
Copy link

tophf commented Jan 25, 2022

How do we move a local per-project node_modules from the project's folder to another drive/folder now?

@ljharb
Copy link
Contributor

ljharb commented Jan 25, 2022

@tophf a hard link? generally you don't; a local project, including its node_modules folder, should be kept all on the same drive and in the same location.

@tophf
Copy link

tophf commented Jan 25, 2022

How do we make a hardlink for a directory in Windows, which can only make junctions or symlinks?

@wraithgar
Copy link
Member

Closing as duplicate of #4358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Triage needs review for next steps ws:arborist Related to the arborist workspace
Projects
None yet
Development

No branches or pull requests

5 participants