首页 技术 正文
技术 2022年11月16日
0 收藏 725 点赞 4,333 浏览 2549 个字

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

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

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

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

npm install -g @angular/cli

这里没问题

2.创建一个Angular项目

ng new angular-demo

这一步报错了:

E:\wsl2019\my-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\n7o7pADTdBhux
yQ’

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-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/ 查看运行效果

Angular7环境搭建报错

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

https://www.angular.cn/tutorial

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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,029
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,519
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,367
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,859