zoukankan      html  css  js  c++  java
  • Angular7环境搭建报错

    昨天写的2019年Angular7——安装搭建路由方法不太正统,今天又去翻了下angular官网,跟着上面的环境搭建与部署走了一遍

    从安装@angular/cli命令行工具开始

    本篇主要记录下搭建过程中的报错

    1.根据官网教程,首先安装cli

    npm install -g @angular/cli

    这里没问题

    2.创建一个Angular项目

    ng new angular-demo

    这一步报错了:

    E:wsl2019my-projects>ng new angular-demo
    ? Would you like to add Angular routing? Yes
    ? Which stylesheet format would you like to use? SASS [ http://sass-lang.com

    ]
    CREATE angular-demo/angular.json (3910 bytes)
    CREATE angular-demo/package.json (1311 bytes)
    CREATE angular-demo/README.md (1028 bytes)
    CREATE angular-demo/tsconfig.json (435 bytes)
    CREATE angular-demo/tslint.json (2824 bytes)
    CREATE angular-demo/.editorconfig (246 bytes)
    CREATE angular-demo/.gitignore (587 bytes)
    CREATE angular-demo/src/favicon.ico (5430 bytes)
    CREATE angular-demo/src/index.html (298 bytes)
    CREATE angular-demo/src/main.ts (372 bytes)
    CREATE angular-demo/src/polyfills.ts (3571 bytes)
    CREATE angular-demo/src/test.ts (642 bytes)
    CREATE angular-demo/src/styles.sass (80 bytes)
    CREATE angular-demo/src/browserslist (388 bytes)
    CREATE angular-demo/src/karma.conf.js (980 bytes)
    CREATE angular-demo/src/tsconfig.app.json (166 bytes)
    CREATE angular-demo/src/tsconfig.spec.json (256 bytes)
    CREATE angular-demo/src/tslint.json (314 bytes)
    CREATE angular-demo/src/assets/.gitkeep (0 bytes)
    CREATE angular-demo/src/environments/environment.prod.ts (51 bytes)
    CREATE angular-demo/src/environments/environment.ts (662 bytes)
    CREATE angular-demo/src/app/app-routing.module.ts (245 bytes)
    CREATE angular-demo/src/app/app.module.ts (393 bytes)
    CREATE angular-demo/src/app/app.component.html (1152 bytes)
    CREATE angular-demo/src/app/app.component.spec.ts (1113 bytes)
    CREATE angular-demo/src/app/app.component.ts (217 bytes)
    CREATE angular-demo/src/app/app.component.sass (0 bytes)
    CREATE angular-demo/e2e/protractor.conf.js (752 bytes)
    CREATE angular-demo/e2e/tsconfig.e2e.json (213 bytes)
    CREATE angular-demo/e2e/src/app.e2e-spec.ts (624 bytes)
    CREATE angular-demo/e2e/src/app.po.ts (239 bytes)
    npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, fl
    atted is its successor.
    npm ERR! Unexpected end of JSON input while parsing near '...75V1G 7o7pADTdBhux
    yQ'

    npm ERR! A complete log of this run can be found in:
    npm ERR! C:UsersAdministratorAppDataRoaming pm-cache\_logs2019-01-30T0
    1_13_57_818Z-debug.log
    Package install failed, see above.

    我搜了一圈,最终:

    npm uninstall -f -g @angular/cli
    npm cache clean --force
    npm install -g @angular/cli@latest

    解决了。答案来自:https://stackoverflow.com/questions/44552025/package-install-failed-angular-on-vagrant

    重新创建项目

    ng new angular-demo

    当然之前创建的同名目录要删掉或者换一个项目名称重新构建,里面会有残留的文件导致无法创建新的项目

    现在代码正常运行

    cd angular-demo
    ng serve

    打开 http://localhost:4200/ 查看运行效果

     

     

    接下来跟着Angular官网-教程-英雄指南的例子走一遍

    https://www.angular.cn/tutorial

    你将学到足够的 Angular 知识,并确信 Angular 确实能提供你所需的支持。

     

     

  • 相关阅读:
    .NetCore(四) 在Nginx部署
    .Net Core(三)MVC Core
    .Net Core(二)EFCore
    .Net Core(一)环境搭建与基本使用
    Linux初体验
    Angular基础(八) Observable & RxJS
    Angular基础(七) HTTP & Routing
    Angular基础(六) DI
    Angular基础(五) 内建指令和表单
    Angular基础(四) 创建Angular应用
  • 原文地址:https://www.cnblogs.com/cathy1024/p/10337092.html
Copyright © 2011-2022 走看看