问题
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.
回答1:
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.
回答2:
This happened to me - the fix on Windows was to go to c:\Users{username}.npmrc and remove the prefix.
回答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.
来源:https://stackoverflow.com/questions/50653324/why-does-npm-install-a-bunch-of-cmd-files-on-my-project-root-folder