Visual Studio always restores NPM packages in System32 directory

I’m having trouble with the package restore feature in Visual Studio. Every time I right-click on my package.json file and select ‘Restore Packages’, it looks for the file in the System32 folder instead of my project directory. Here’s what I see in the output:

npm WARN ENOENT ENOENT: no such file or directory, open 'C:\Windows\System32\package.json'
npm WARN EPACKAGEJSON C:\Windows\System32 No description
npm WARN EPACKAGEJSON C:\Windows\System32 No repository field.

This happens with both NPM and Bower. I’ve tried a few things, but nothing seems to work. The restore command always checks System32 instead of my actual project folder.

Does anyone know how to fix this? I’m using Visual Studio 2015 and just want the package restore to work correctly in my project directory. Any help would be really appreciated!

hey there, i’ve run into this before. try checkin ur VS external tools config. go to Tools > Options > Projects and Solutions > External Web Tools. make sure ur node.js path is at the top. that usually fixes it. if not, maybe try runnin VS as admin? good luck!

Have you tried clearing your NPM cache? Sometimes that can help with weird package restore issues. Open a command prompt and run ‘npm cache clean --force’. Then restart Visual Studio and try the restore again. If that doesn’t work, you might want to check your system PATH variables to make sure they’re pointing to the right Node/NPM versions. Also, double-check that your project’s node_modules folder isn’t somehow linked to System32. Worst case, you could try uninstalling and reinstalling Node.js and NPM. It’s a pain, but it might reset things properly. Hope you get it sorted out soon!

I’ve faced this annoying issue before too. What worked for me was tweaking the PATH environment variable. Right-click on ‘This PC’, go to Properties > Advanced system settings > Environment Variables. In the System variables section, find PATH and edit it. Make sure the path to your Node.js installation is at the top of the list. This should force VS to use the correct Node/NPM versions.

Another thing to check - sometimes antivirus software can interfere with npm. Try temporarily disabling your antivirus and see if that helps. If all else fails, you might need to repair or reinstall Visual Studio. It’s a pain, but sometimes it’s the only way to fix weird config issues like this.

Remember to restart VS after making any changes. Hope this helps you get it sorted!