美文网首页
centos配置angular运行环境

centos配置angular运行环境

作者: 没有故事的老大爷 | 来源:发表于2018-06-22 17:08 被阅读0次

一、 编译源码安装

  1. nodejs官网下载源码
  1. 上传解压
tar xzvf node-v8.11.3.tar.gz
cd node-v8.11.3/
./configure
  • 如果出现了如上警告: c++ comiler too old建议使用第二种nvm方式安装,事实上nvm方式安装更简单方便
  1. 编译安装(时间较长,请耐心等待)
make && make install
笔者当时没有截图,这里直接盗用参考文章的截图
  1. 查看是否安装成功
node -v
npm -v

5.配置淘宝镜像,加速资源下载

npm config set registry  https://registry.npm.taobao.org
npm install -g cnpm --registry=https://registry.npm.taobao.org
  1. angular-cli是用typescript写的,所以需要全局安装typescript和typings
  • 由于npm安装插件是从国外服务器下载,受网络影响很大,可能出现异常,淘宝团队生产了一个完整的npmjs.org镜像,用cnpm代替npm,cnpm与nodejs的npm用法一致,只是在执行命令时,将npm改为cnpm。
cnpm install -g typescript typings
  1. 查看typescript版本
 tsc -v
  1. 安装angular cli
cnpm install -g angular-cli@latest

安装后使用ng -v验证


  1. 创建一个测试项目
ng new hello-world --skip-install
  1. 编译产生dist文件夹
ng build
# 如果在build时报错:You have to be inside an angular-cli project in order to use the build command after reinstall of angular-cli](https://stackoverflow.com/questions/39133782/you-have-to-be-inside-an-angular-cli-project-in-order-to-use-the-build-command-a)
# 请重新使用npm安装angular cli
npm install -g @angular/cli@latest
 
  1. 安装图表模块

npm install @antv/g2 --save

  1. 好了,现在可以使用ngix或者tomcat解析页面了。

二、 nvm安装node (Node Version Manager)

  1. 安装git
sudo yum install git
  1. wget安装nvm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

source ~/.bashrc
  1. 验证安装成功
nvm
  1. 列出可以安装的版本号
nvm ls-remote
# 我这里已经安装了 v8.11.3和v10.5.0
  1. 安装指定版本
nvm install v10.5.0
  1. 切换版本和查看当前版本、查看已安装的版本
nvm use v10.5.0
nvm current
nvm ls

作者 @没有故事的老大爷
只要最后是你,就好

相关文章

网友评论

      本文标题:centos配置angular运行环境

      本文链接:https://www.haomeiwen.com/subject/zuikyftx.html