Angular环境搭建

在这里插入图片描述

Angular环境搭建

1 .安装前环境准备
  • 安装nodejs(安装稳定版本)

  • 安装cnpm

    • npm install -g cnpm --registry=https://registry.npm.taobao.org
      
2.全局安装Angular/cli(只需要安装一次)
  • npm install -g @angular/cli     或者    cnpm install -g @angular/cli
    
  • 验证是否安装成功 终端输入 ng v出现下面相似的提示表示成功

  •     _                      _                 ____ _     ___    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
      / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
     / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | | /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                   |___/
                    Angular CLI: 8.3.21
    
      Node: 10.16.2
    
      OS: win32 x64
    
      Angular:
    
      Package                      Version
    
      @angular-devkit/architect    0.803.21
    
      @angular-devkit/core         8.3.21
    
      @angular-devkit/schematics   8.3.21
    
      @schematics/angular          8.3.21
    
      @schematics/update           0.803.21
    
      rxjs                         6.5.4
    
    

2项目创建第一种方式

  • 在需要创建项目的文件夹下打开命令提示行

  • 创建项目

    • 在终端中输入ng new 项目名称
    • 项目名称建议命名为英文
  • 安装会出现的提示

    • Would you like to add Angular routing?表示是否安装路由

    • Which stylesheet format would you like to use?样式文件编译

    • 出现下面提示表示成功

    •     ? Would you like to add Angular routing? Yes
          ? Which stylesheet format would you like to use? Sass   [ https://sass-lang.com/documentation/syntax#the-indented-syntax ]
          CREATE angular01/angular.json (3705 bytes)
          CREATE angular01/package.json (1295 bytes)
          CREATE angular01/README.md (1027 bytes)
          CREATE angular01/tsconfig.json (543 bytes)
          CREATE angular01/tslint.json (1953 bytes)
          CREATE angular01/.editorconfig (246 bytes)
          CREATE angular01/.gitignore (631 bytes)
          CREATE angular01/browserslist (429 bytes)
          CREATE angular01/karma.conf.js (1021 bytes)
          CREATE angular01/tsconfig.app.json (270 bytes)
          CREATE angular01/tsconfig.spec.json (270 bytes)
          CREATE angular01/src/favicon.ico (948 bytes)
          CREATE angular01/src/index.html (295 bytes)
          CREATE angular01/src/main.ts (372 bytes)
          CREATE angular01/src/polyfills.ts (2838 bytes)
          CREATE angular01/src/styles.sass (80 bytes)
          CREATE angular01/src/test.ts (642 bytes)
          CREATE angular01/src/assets/.gitkeep (0 bytes)
          CREATE angular01/src/environments/environment.prod.ts (51 bytes)
          CREATE angular01/src/environments/environment.ts (662 bytes)CREATE angular01/src/app/app-routing.module.ts (246 bytes)
          CREATE angular01/src/app/app.module.ts (393 bytes)
          CREATE angular01/src/app/app.component.html (25530 bytes)
          CREATE angular01/src/app/app.component.spec.ts (1107 bytes)
          CREATE angular01/src/app/app.component.ts (214 bytes)
          CREATE angular01/src/app/app.component.sass (0 bytes)
          CREATE angular01/e2e/protractor.conf.js (808 bytes)
          CREATE angular01/e2e/tsconfig.json (214 bytes)
          CREATE angular01/e2e/src/app.e2e-spec.ts (642 bytes)
          CREATE angular01/e2e/src/app.po.ts (262 bytes)
          npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
      
          > core-js@2.6.11 postinstall F:\htmldaima\angular\angular01\node_modules\babel-runtime\node_modules\core-js
          > node -e "try{require('./postinstall')}catch(e){}"
              > core-js@3.2.1 postinstall F:\htmldaima\angular\angular01\node_modules\core-js
          > node scripts/postinstall || echo "ignore"
              > core-js@2.6.11 postinstall F:\htmldaima\angular\angular01\node_modules\karma\node_modules\core-js
          > node -e "try{require('./postinstall')}catch(e){}"    > @angular/cli@8.3.21 postinstall F:\htmldaima\angular\angular01\node_modules\@angular\cli
          > node ./bin/postinstall/script.js
      
          npm WARN karma-jasmine-html-reporter@1.5.1 requires a peer of jasmine-core@>=3.5 but none is installed. You must install peer dependencies yourself.
          npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\webpack-dev-server\node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
          npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\watchpack\node_modules\fsevents):
          npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
          npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\karma\node_modules\fsevents):
          npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
          npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\@angular\compiler-cli\node_modules\fsevents):
          npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
          npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
          npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
      
          added 1193 packages from 1051 contributors and audited 18835 packages in 181.192s
          found 0 vulnerabilities
      
          warning: LF will be replaced by CRLF in .editorconfig.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in .gitignore.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in README.md.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in angular.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in browserslist.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in e2e/protractor.conf.js.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in e2e/src/app.e2e-spec.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in e2e/src/app.po.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in e2e/tsconfig.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in karma.conf.js.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in package-lock.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in package.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/app/app-routing.module.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/app/app.component.html.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/app/app.component.spec.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/app/app.component.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/app/app.module.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/environments/environment.prod.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/environments/environment.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/index.html.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/main.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/polyfills.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/styles.sass.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in src/test.ts.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in tsconfig.app.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in tsconfig.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in tsconfig.spec.json.
          The file will have its original line endings in your working directory
          warning: LF will be replaced by CRLF in tslint.json.
          The file will have its original line endings in your working directory
              Successfully initialized git.
      

项目创建第二种方式

  • 在需要创建项目的文件夹下打开命令提示行
  • 创建项目
    • 在终端中输入ng new 项目名称 --skip-install ;这样只会新建项目不会安装依赖
    • 项目名称建议命名为英文
  • 进入新创建的文件夹下使用npm或者cnpm安装
    • cnpm安装比较快

运行项目

  • cd 项目文件夹名称
    
  • ng serve --open
    
  • 出现下图表示运行成功
    在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值