Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install @angular/common/http using npm

Tags:

npm

angular

Until yesterday, I was able to download @angular/common/http package. However starting from today, every time I issue

npm i

command, I get the following error:

npm ERR! code EINVALIDPACKAGENAME npm ERR! Invalid package name "@angular/common/http": name can only contain URL- friendly characters

People have suggested to upgrade/downgrade npm which I have tried but no luck so far.

package.json

"dependencies": {
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/common/http": "^5.0.0",

Any ideas guys? let me know if you need more info.

Thanks

like image 464
Robert Dinaro Avatar asked Jan 19 '18 13:01

Robert Dinaro


People also ask

Is npm required for angular?

Angular, the Angular CLI, and Angular applications depend on npm packages for many features and functions. To download and install npm packages, you need an npm package manager. This guide uses the npm client command line interface, which is installed with Node.js by default.

Can we use npm package in angular?

Libraries are published as npm packages, usually together with schematics that integrate them with the Angular CLI. To integrate reusable library code into an application, you need to install the package and import the provided functionality in the location you use it.


1 Answers

The @angular/common/http module is part of the @angular/common module. You only need to include @angular/common within your dependencies, not the http module as well.

Adding @angular/common/http to your package json will try to include it a second time when you already have it. Remove it, delete your node_modules folder and rerun npm install

like image 161
mast3rd3mon Avatar answered Sep 29 '22 23:09

mast3rd3mon