16

Why does npm install a bunch of files and .cmd files on my root folder? If I remove the files and run npm install again, those .cmd files will reappear. Why doesn't npm download those files and stored it into node_modules folder?

When I clone the repo in another computer, it doesn't create those .cmd files. Both computer are running windows 10.

After several testing, I found out that if I delete package-lock.json file first then only perform npm install, then those .cmd won't appear, but then now the project fails to start.

screenshot of project root folder

screenshot of package.json file

gunr2171
  • 16,104
  • 25
  • 61
  • 88
Andrew Lam
  • 3,675
  • 4
  • 23
  • 34
  • Having the same issue on a project and we're basically diff'ing the before and after npm install to see what files were dumped, then removing them. – Ryan Rife Dec 04 '18 at 20:48

4 Answers4

7

This happened to me - the fix on Windows was to go to c:\Users\{username}\.npmrc and remove the prefix.

Ε Г И І И О
  • 11,199
  • 1
  • 48
  • 63
Sean Chase
  • 1,139
  • 1
  • 15
  • 23
4

If this is only reproducible when using prefix then it is very possible that it is a bug in npm (there is a similar issue in pnpm that I was going to fix).

There is no workaround to this at the moment. There are no configs to set the bin location. So you should avoid using the prefix config until npm fixes the issue.

Zoltan Kochan
  • 5,180
  • 29
  • 38
3

The problem is solved when I run npm install directly in the folder instead of using npm install --prefix.

This was extracted from the question post and moved here on the author's behalf.

gunr2171
  • 16,104
  • 25
  • 61
  • 88
0

I solved the problem by resetting node js config

Here is doc how to do it