Support global 'node_modules'

Hello,I would like to have a global repo like ‘maven’ that we can download the dependencies to the global repo with ‘package.json’.
Becauses:
To save time on downloading the dependeces.
Take up less memory.

Not sure what exactly the use-case would be here, but I suggest reading up Node’s documentation on the topic of global folders as that might be a helpful start:
https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders

But I want to download the dependencies to the global repo with package.json that we can share rope with team members.And how can I distinguish version of dependencies?

I am not sure what you are asking.
Are you interested in a local caching npm repository for your team?
Or shared packages across packages on your local computer?

We’ll download dependencies into APP/node_modules when npm install executed.
I have many apps, so there are many APP/node_modules in my PC.
I am asking a GLOBAL/node_modules to instead of many APP/node_modules,and I can npm install dependencies into the GLOBAL/node_modules.

  1. A future direction for the npm tool is automatically install only one copy of each version of a package for your computer. (I think I heard in a conference talk this is intended for npm 8.)

You can read about it a little here from an announcement last year, the working name for the program is “tink”: https://blog.npmjs.org/post/178027064160/next-generation-package-management

And there are also posts about tink in #development in this forum, and zcat talked about it at a recent jsconf conference.

  1. I don’t think there is direct support in npm for this, but there are other package managers with different feature sets, such as: https://pnpm.js.org
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.