重装@angular/cli reason: write EPROTO 139955972261696:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:252:

前几天不小心卸载了 angular@cli,然后重装的时候发现,一直报错。如下:

××××××××@××××ln622653:/$ npm install -g @angular/cli
npm ERR! code EPROTO
npm ERR! errno EPROTO
npm ERR! request to https://registry.npmjs.org/@angular%2fcli failed, reason: write EPROTO 139822307051328:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:252:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jiangdaowen/.npm/_logs/2018-08-20T01_58_47_424Z-debug.log

也试过网上面说的要先安装npm install -g typescript typings,也是如下报错:

npm ERR! code EPROTO
npm ERR! errno EPROTO
npm ERR! request to https://registry.npmjs.org/typescript failed, reason: write EPROTO 139955972261696:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:252:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /home/jiangdaowen/.npm/_logs/2018-08-20T01_59_11_990Z-debug.log

node 和npm都是没有问题的,通过node -v和npm -v都能显示出版本,我这里的版本是node=> v10.8.0,npm=>

6.2.0.

因为我们公司的网络需要用代理才能下载浏览相关网页。后来发现是要设置一个代理和仓库地址,有两种方式,如下:

1》一种是通过命令来设置。npm config set proxy=http://我是账号:我是密码@143.116.28.61:64000/

    其中143.116.28.61是代理的地址,64000是代理的端口。

      设置完代理之后,在设置一个的仓库地址   npm config set registry=http://registry.npmjs.org

  设置完成之后,系统会自动写入到.npmrc 文件

 

2?》还可以写到隐藏文件里面来。在linux的unbutu系统里面可以在home路径下面,按住Ctrl+h显示隐藏文件,找到.npmrc 文件。直接添加代理和仓库地址

     现在在输入安装命令:npm install -g @angular/cli

  ng -v  就可以看到版本号啦。

我这里写的是其中的个别错误的解决方案,事实上npm和ng 很容易出问题。特别是install和安装卸载的时候,很多种原因会导致失败。

附上安装node和npm的简易方式,绝对不会出错的方式。很简单:

 

angularjs环境配置
1.下载nodejs安装包,解压到不需要sudo权限的地址。
2. 修改.bashrc文件()

  export NodeJS=/opt/local/node-v9.4.0-linux-x64 (你的nodejs的存放地址)
  export PATH=${JAVA_HOME}/bin:$NodeJS/bin:$PATH

 3. source ~/.bashrc (修改全局变量之后使其立即生效)
 4. 配置代理 npm config set proxy=http://duncan_jiang:*****@143.116.28.61:64000/   (代理选用,看你自己的网络是不是需要代理,如果不需要代理就直接设置仓库地址就好了。)
   配置仓库地址:npm config set registry=http://registry.npmjs.org
4. npm install -g @angular/cli

 5. ng -v查看版本

小提示:当你没有安装好cli时,而ng server --open 启动项目报错,可以使用 npm start启动

  

posted @ 2018-08-20 10:46  月亮那么僵  阅读(13113)  评论(0编辑  收藏  举报