22

I am new to "@angular/cli", I have tried every thing but could not install. I am tired now please some one can help me to install angular 4 "@angular/cli" in my system.

node and npm Version enter image description here

and when I am installing "npm install -g @angular/cli" then getting enter image description here

after installing node -v 6 I am getting below erorr enter image description here

please suggest me where actually I am wrong.

Saurabh Agrawal
  • 7,581
  • 2
  • 27
  • 51
Rajpurohit
  • 1,951
  • 2
  • 16
  • 19

24 Answers24

17

My friend,

Please try: npm cache clean --force. Maybe your npm cache got confused.

ga.breban
  • 276
  • 1
  • 5
11

It could be issue with your node version. I will suggest you to reinstall node and try it again.

Or you can also try to clean node cache of using npm cache clean --force

Saurabh Agrawal
  • 7,581
  • 2
  • 27
  • 51
  • I did it many and many time, I have installed below versions: 1. node-v8.9.1-x64. 2.node-v9.2.0-x64 3.currently installed node-v9.2.0-x86 but not work for me. – Rajpurohit Dec 06 '17 at 09:25
  • v9.2.0 : node -v – Rajpurohit Dec 06 '17 at 09:30
  • 2
    I think you jumped from one unsupported node version to the next. try to downgrade to node v8.9.2 as there are some complains about @angular/cli not working with node >9.0.0 >> https://github.com/angular/angular-cli/issues/8757 – Denis Dec 11 '17 at 09:49
9

List of Npm registry

To switch just type

npm config set registry "https://registry.npmjs.org/"

Replace the registry url with the above urls check which one works for you.

I am from india so i used https://r.cnpmjs.org/ and the same error got resolved.

Note: Please use npm cache clear (To clear cache ) and npm cache verify (To verify its clear or not), This Method works for me

Rakesh Roy
  • 930
  • 2
  • 12
  • 22
  • Your solution work but now I am getting below error: "npm ERR! code EINTEGRITY npm ERR! sha1-zBJg9RyQCp7A2R+2mYE54CUHtjs= integrity checksum failed when using sha1: wanted sha1-zBJg9RyQCp7A2R+2mYE54CUHtjs= but got sha1-tniyCZYaGgDcMJSbSwpymUqc6LE=. (98878 bytes)" – Rajpurohit Dec 11 '17 at 12:20
  • I think your npm is cached, Please Uninstall Npm completely ( https://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows ). and Restart your PC , Then Try Install and Check . If you are from India (Asia) Please use http://r.cnpmjs.org/ and then switch to default . It will Work, I formatted my pc several times after this error. but resolved after switching reg url. – Rakesh Roy Dec 12 '17 at 07:31
1

Changing Registry location worked for me . Using :

npm config set registry "https://registry.npmjs.org/"

few warnings but meh! life's too short for warnings.(Every thing is working fine BTW)

0

It is possible your npm cache has a corrupted file, perhaps it partially downloaded something and then got an error. Try npm cache clean --force and see if that helps.

If that doesn't help look in the log file given in the error message. Find the unexpected end of JSON input message in the log file and look before it to see if there are any other hints to the problem.

You updated your question with a new error message. That one is more specific about the corrupted file. Try removing the cli-1.5.5.tgz file from the path specified and try again. If you are using a web proxy on your network then it is also possible that your proxy has stored a corrupted cache: if you are able then turn off any proxies configured for your system and try a direct download.

Duncan
  • 92,073
  • 11
  • 122
  • 156
  • I have delete all file from "npm-cache" and run command again but still getting the same. – Rajpurohit Dec 06 '17 at 09:47
  • actually that time I have installed "node-v6.2.2-x64.msi" now I have re-installed "node-v8.9.1-x64.msi" and getting error "Unexpected end of JSON input while parsing near '...d13a3f04e30428f68d1b0'" – Rajpurohit Dec 06 '17 at 10:13
  • can we talk on skype? if you can do then it will be good for me – Rajpurohit Dec 06 '17 at 10:17
0

Perhaps you are missing space- npm install -g @angular/cli@latest

 1) Install node.js and check and node -v in command prompt. (Node.js 
       through website).
2) npm install -g @angular/cli@latest (run in command prompt).
Refer this link for further help

https://github.com/angular/angular-cli

    3) Check node -version
    4) Check npm -version
    5) check ng -version

    If already installed, then uninstall it and install again,
    npm uninstall -g @angular/cli
    npm cache clean
Mahi
  • 3,748
  • 4
  • 35
  • 70
0

Both the CLI and generated project have dependencies that require Node 6.9.0 or higher, together with NPM 3 or higher.

Try using different Node version.

  • I have already used all latest version of Node but every time getting same issue. – Rajpurohit Dec 11 '17 at 08:30
  • npm cache clean --force If it didn't work, just completely uninstall the Node.js from Programs and Features and Re-install it. Make sure that you completely deleted all the node-modules and npm caches in the Npm folder and is not present anywhere else. – Shiha Mohan Dec 11 '17 at 09:09
0

First try updating NodeJS(8.9.3) and npm(5.6.0). These are the LTS versions. For Node this can be important! If that doesn't work, follow this installation guide for windows.

Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116
0

Make sure you are not connected to VPN while installation is on.

Also, please cleanup your node_modules folder before your next try. I use the command rimraf node_modules to remove this directory in windows.

Lastly try running npm install -g @angular/cli@latest

pixlboy
  • 1,452
  • 13
  • 30
  • How to check VPN? – Rajpurohit Dec 12 '17 at 15:50
  • VPN is usually used in corporate machines, if you are on your personal computer, then it may not be a VPN issue at all. Can you try removing Node JS completely and then install a fresh copy again ? – pixlboy Dec 13 '17 at 05:40
  • Not sure but can you try running this command as an admin before anything else. npm install --global --production windows-build-tools – pixlboy Dec 20 '17 at 06:49
0

run npm install -g @angular/cli@latest in command prompt as an admin.

right click the windows button, click on command propmt (Admin) or windows power shell(Admin) depending on your windows version. Then type the command and run it.

Most times, you could get issues when you want to install as a normal user considering the fact that you are using the -g (global) flag.

Ifesinachi Bryan
  • 2,240
  • 1
  • 19
  • 20
0

We too have the same kind of issue with user login then we tried from Administrator login its worked for us. Please do the same it may fix for you too.

Muthamizhchelvan. V
  • 1,241
  • 1
  • 17
  • 30
0

Please try running:

rm -rf node_modules package-lock.json

And this,

npm install

If it still does not work, try to manually install cli:

npm install --save-dev @angular/cli

0

When an npm package is published, the publishing process generates a checksum that npm uses at install time to verify that the package didn't get corrupted in transit.

I had the exact same problem, while i was working in a client site, so the problem could be not your environment, they may have a proxy that needs to be configured, in my case we had a nexus server we were going through, and it has something wrong, but when i started using npm registry directly everything worked fine, but most of the time it's a cache problem, to be sure of that you should run:

npm doctor

you will probably find where is the issue. if not please post the result maybe i can help.

Ayoub
  • 112
  • 1
  • 9
0
  1. Make sure your console is running as Admin,
  2. Reinstall node & npm
  3. Reinstall angular/cli
Frank Odoom
  • 1,545
  • 18
  • 19
0

Most probable issue is with npm cache. Just clean your npm cache by command

npm cache clean --force

It should work well.

Pullat Junaid
  • 3,224
  • 3
  • 25
  • 25
0

Uninstall your node package. And try the following

  1. Install the latest node package from https://nodejs.org/en/download/

  2. Check your node and npm version by

node -v

npm -v

  1. Now install the Angular latest version by

npm install -g @angular/cli

  1. Check the angular version by

ng v

  1. Now start creating your application from https://angular.io/guide/quickstart
Vignesh
  • 1,521
  • 1
  • 12
  • 11
0

So I'm working with Hyperledger which requires you to have a certain Node version 8 and therefore you cannot use the newest angular installation. Perhaps I can recommend another alternative?

cd into the directory

npm install
npm start

You can also clean your npm cache but if one way doesn't work, try the other.

0

Try navigating to /usr/local/bin and :
if check if the file named ng is present over there,
if yes then rm -r ng and it will remove that file.
Then you can try sudo npm i -g @angular/cli@latest And it will be a successful install.

(Writing this for those who might also face this issue in future)

0

Npm cache clean --force Then install npm Then go for angular Npm I -g @angular/cli

0

was having a similar issue while installing angular cli using npm. enter image description here

this was resolved by running: npm cache clean --force

Pope Francis
  • 557
  • 8
  • 9
0

It happened to me once, looked like I had to specify the version of angular cli: https://github.com/angular/angular-cli/issues/11589 e.g.: npm install -g @angular/cli@1.5.0

Yuqiu G.
  • 348
  • 4
  • 7
0

Strictly to those working in an IT firm and simply want to resolve this issue in your compliance laptop.

First set the directory where you would like create your project using 'cd'.

Steps to start workspace-

  1. npm config set registry https://infyartifactory.ad.infosys.com/artifactory/api/npm/npm
  2. npm login Then enter infy credentials.
  3. npm i -g config
  4. npm install -g ts-node

Steps to create new ANGULAR project-

  1. install angular- npm i -g @angular/cli[@vs_code_version] (stable version is @13.1.3) ( You can also run project with command 'npm run ng serve')
  2. create new project- ng new AngularDemo Then select y and CSS
  3. Run the angular project if required- ng s --o
  4. install bootstrap (optional) npm install bootstrap --save
  5. Generate component ng g c first ng g c second lazy loading component generation 6 ng g m admin --route admin --module app.module
0

I face the same problem

npm resolution error report

While resolving: erp-web@0.0.0 Found: @angular/core@13.0.3 node_modules/@angular/core @angular/core@"~13.0.0" from the root project

Could not resolve dependency: peer @angular/core@"13.3.12" from @angular/animations@13.3.12 node_modules/@angular/animations @angular/animations@"^13.1.0" from the root project

Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.

Just I use npm i --force
done this work for me . you can see more here.

-1

It could be issue with your node version. I will suggest you to reinstall node and try it again.

Or you can also try to clean node cache of using npm cache clean --force

Please check this also Perhaps you are missing space- npm install -g @angular/cli@latest

sameer joshi
  • 377
  • 2
  • 8
  • 27