ReaganS94
ReaganS94

Reputation: 87

npm "Invalid response body while trying to fetch". npm can't install any dependencies

Good day everyone! I recently worked through this error message:

npm WARN config global --global, --local are deprecated. Use --location=global instead

by editing the 4 necessary files (npm, npm.cmd, npx, npx.cmd). Problem is, now I can't install any dependency and I can't use npx (for example for npx create-react-app my-app).

When trying to install a dependency

Running npx

What I have tried so far:

On the flip side yarn seems to be working so I have no problems running yarn add express for example. Any help would be very much appreciated!

Upvotes: -1

Views: 10270

Answers (1)

Ehsan Motamedi
Ehsan Motamedi

Reputation: 19

The solution I followed to solve this problem:

1 - Go to folder C:\Program Files\nodejs

2 - You have to edit 4 files named : npm, npm.cmd, npx, npx.cmd

3 - Open the files in a text editor, like [ Visual Studio Code ]

4 - Replace prefix -g with prefix with location=global in all 4 files, make sure didn't use -- and Save all (if asked, save as administrator)

Like a picture.

Good to go!

(https://user-images.githubusercontent.com/104328686/179422998-5b3f36c8-6b03-4b2b-95be-36f1cf3a2d80.PNG)

Upvotes: 1

Related Questions