4

Usually when I do 'npm install' inside my application directory, bunch of npm libraries files gets generated inside node_modules folder which is expected. Today suddenly I started seeing many files getting generated inside application directory and outside node_modules.

Did anyone face this issue ? and if yes - any workaround ? Screenshot attached. Lot's of .cmd file, don't know why they are here.

My application folder structures

Rajeev Jayaswal
  • 1,423
  • 1
  • 20
  • 22
  • Why do you think these files are unnecessary ? Sounds like batch versions of the bash scripts. – TGrif Dec 30 '17 at 22:03
  • Coz when I did 'npm install' in ubuntu, it didn't generate all such files outside node_modules. It started creating now in windows npm. – Rajeev Jayaswal Jan 02 '18 at 08:10
  • Maybe it's plateform specific. What does the npm _install_ script look like ? – TGrif Jan 02 '18 at 09:12
  • Yeah, may be on windows only those .cmd files get generated. By theway, npm install calls "node-gyp rebuild" and node-gyp is script present at https://github.com/nodejs/node-gyp/blob/master/bin/node-gyp.js – Rajeev Jayaswal Jan 02 '18 at 16:07
  • I don't think _node-gyp_ creates files on its own. Anyway I guess you can always manually remove the files you don't need in your project. – TGrif Jan 02 '18 at 18:33
  • So these files should normally be created in the node_modules folder, beside the package.json file. As @sean-chase alluded to, the "prefix" property can cause this behaviour. It might be defined in a .npmrc file (which might be defined in several places) or it might even be supplied to the npm install command: npm install --prefix=. foo – Ken Lyon Mar 21 '19 at 22:12

2 Answers2

2

Edit your c:\Users{username}.npmrc and remove the prefix.

Sean Chase
  • 1,139
  • 1
  • 15
  • 23
0

I had the same issue, and was able to resolve this by completely uninstalling + re-installing Node/npm:

How to completely remove node.js from Windows

Jason
  • 49
  • 2