Not able to install @angular/cli using npm

半腔热情 提交于 2019-12-18 01:56:32

问题


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

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

after installing node -v 6 I am getting below erorr

please suggest me where actually I am wrong.


回答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




回答2:


My friend,

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




回答3:


List of Npm registry

  • https://registry.npmjs.org/ (Dfault One)
  • http://r.cnpmjs.org/
  • https://registry.npm.taobao.org/
  • https://registry.nodejitsu.com/
  • http://registry.mirror.cqupt.edu.cn
  • https://skimdb.npmjs.com/registry

To switch just type

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

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

I am from india so i used http://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




回答4:


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.




回答5:


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



回答6:


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.




回答7:


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.




回答8:


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




回答9:


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.




回答10:


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.




回答11:


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




回答12:


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.




回答13:


  1. Make sure your console is running as Admin,
  2. Reinstall node & npm
  3. Reinstall angular/cli



回答14:


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

npm cache clean --force

It should work well.




回答15:


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



回答16:


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.




回答17:


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



来源:https://stackoverflow.com/questions/47670693/not-able-to-install-angular-cli-using-npm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!