-1

Currently I've installed Node.js and npm on my Windows 10 and first package called hotkeys-js. I have no idea why I have least two node_modules directories within distinct paths, i.e.:

one in

C:\Program Files\nodejs\node_modules\npm

which I do consider as parent working directory, correct if I am wrong?

second which is most questionable for me:

C:\Users\<*whateverUsernameWouldBe*>\node_modules\first_npm

also the structure within first_npm as:

|- node_modules
|- index.js
|- package.json
|- package-lock

Why do I have this separate directory at all? Is it local/global? What is the purpose of this one?

E_net4
  • 27,810
  • 13
  • 101
  • 139
projektorius96
  • 114
  • 2
  • 10
  • 1
    Does this answer your question? [Where does npm install packages?](https://stackoverflow.com/questions/5926672/where-does-npm-install-packages) – E_net4 Jan 03 '21 at 15:13
  • @E_net4theposteditor First of all let me thank you for editing the post I've submitted. The answer to your question unfortunately is negative this time. No it does not answer to my question. – projektorius96 Jan 03 '21 at 15:27

1 Answers1

1

The node_modules folder under Program Files contains the npm modules installed as part of the nodejs installation package, and the npm modules you install with npm install -g whatever for common, global, use on your machine.

The node_modules folder in your project folder contains the npm modules you installed as part of your project.

Don't mess with the one under Program Files except via npm install -g and npm uninstall -g commands. At least until you get a little more proficient with this stuff.

Your life might be slightly easier if you create your own nodejs / npm projects in a folder called C:\Users\<*whateverUsernameWouldBe*>\myNodeProjects or something like that, rather than a folder called C:\Users\<*whateverUsernameWouldBe*>\node_modules. Folders named node_modules are generally maintained by npm. When you create one that isn't, you can confuse yourself. Ask me how I know this sometime.

O. Jones
  • 103,626
  • 17
  • 118
  • 172