AngularJS安装版本问题解析

 更新时间:2024年02月27日 12:11:54   作者:觉醒法师  
这篇文章主要介绍了AngularJS安装版本问题解析,在这需要注意在安装前请确保自己安装NodeJS环境版本为V18及以上,否则会因node版本问题导致项目无法正常运行,需要的朋友可以参考下

一、安装

Angular CLI 脚手架安装命令:

npm install -g @angular/cli

在安装前请确保自己安装NodeJS环境版本为V18及以上,否则会因node版本问题导致项目无法正常运行。

脚手架安装后,已提示了当前node版本必须为18.13.0或大于20.9.0版本:

在node版本不一致情况下,创建项目会提示Node.js版本必须为v18.13,如下图:

二、匹配版本

本人电脑上使用的node版本为v16,在不升级node版本情况下,可以考虑降低@angular/cli版本,地址:Releases · angular/angular-cli · GitHub

2.1 安装命令

在Releases中找到对应版本进行安装,命令如下:

npm install -g @angular/cli@16.2.6

此时则没有版本问题提示了,如下图:

2.2 创建项目

D:\workspace\web\angular>ng new hello-world
? Would you like to share pseudonymous usage data about this project with the Angular Team
at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more
details and how to change this setting, see https://angular.io/analytics. Yes
Thank you for sharing pseudonymous usage data. Should you change your mind, the following
command will disable this feature entirely:
    ng analytics disable --global
Global setting: enabled
Local setting: No local workspace configuration file.
Effective status: enabled
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? SCSS   [ https://sass-lang.com/documentation/syntax#scss
 ]
CREATE hello-world/angular.json (2899 bytes)
CREATE hello-world/package.json (1042 bytes)
CREATE hello-world/README.md (1064 bytes)
CREATE hello-world/tsconfig.json (901 bytes)
CREATE hello-world/.editorconfig (274 bytes)
CREATE hello-world/.gitignore (548 bytes)
CREATE hello-world/tsconfig.app.json (263 bytes)
CREATE hello-world/tsconfig.spec.json (273 bytes)
CREATE hello-world/.vscode/extensions.json (130 bytes)
CREATE hello-world/.vscode/launch.json (470 bytes)
CREATE hello-world/.vscode/tasks.json (938 bytes)
CREATE hello-world/src/main.ts (214 bytes)
CREATE hello-world/src/favicon.ico (948 bytes)
CREATE hello-world/src/index.html (296 bytes)
CREATE hello-world/src/styles.scss (80 bytes)
CREATE hello-world/src/app/app-routing.module.ts (245 bytes)
CREATE hello-world/src/app/app.module.ts (393 bytes)
CREATE hello-world/src/app/app.component.html (23115 bytes)
CREATE hello-world/src/app/app.component.spec.ts (1006 bytes)
CREATE hello-world/src/app/app.component.ts (216 bytes)
CREATE hello-world/src/app/app.component.scss (0 bytes)
CREATE hello-world/src/assets/.gitkeep (0 bytes)
√ Packages installed successfully.
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 .vscode/extensions.json.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .vscode/launch.json.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .vscode/tasks.json.
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 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/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/styles.scss.
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
    Successfully initialized git.

2.3 运行项目

选择项目目录:

D:\workspace\web\angular>cd hello-world

运行hello-world项目命令如下:

D:\workspace\web\angular\hello-world>ng serve --open
? Would you like to share pseudonymous usage data about this project with the Angular Team
at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more
details and how to change this setting, see https://angular.io/analytics. Yes
Thank you for sharing pseudonymous usage data. Should you change your mind, the following
command will disable this feature entirely:
    ng analytics disable
Global setting: enabled
Local setting: enabled
Effective status: enabled
√ Browser application bundle generation complete.
Initial Chunk Files   | Names         |  Raw Size
vendor.js             | vendor        |   2.35 MB |
polyfills.js          | polyfills     | 333.17 kB |
styles.css, styles.js | styles        | 230.92 kB |
main.js               | main          |  48.74 kB |
runtime.js            | runtime       |   6.52 kB |
                      | Initial Total |   2.96 MB
Build at: 2024-02-26T08:05:28.353Z - Hash: daa545468f767600 - Time: 33009ms
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
√ Compiled successfully.

运行结果下图:

如上图,项目可以正常运行了。

到此这篇关于AngularJS安装版本问题的文章就介绍到这了,更多相关AngularJS安装版本问题内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • AngularJS 指令的交互详解及实例代码

    AngularJS 指令的交互详解及实例代码

    这篇文章主要介绍了AngularJS 指令的交互,这里整理了详细的资料及实例代码,有兴趣的小伙伴可以参考下
    2016-09-09
  • 在 Angular中 使用 Lodash 的方法

    在 Angular中 使用 Lodash 的方法

    这篇文章主要介绍了在 Angular中 使用 Lodash 的方法,需要的朋友可以参考下
    2018-02-02
  • 浅析webapp框架AngularUI的demo

    浅析webapp框架AngularUI的demo

    这篇文章主要介绍了浅析webapp框架AngularUI的demo以及对demo的简单修改,需要的朋友可以参考下
    2014-12-12
  • Angular 数据请求的实现方法

    Angular 数据请求的实现方法

    本篇文章主要介绍了Angular 数据请求的实现方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-05-05
  • Angular4.0中引入laydate.js日期插件的方法教程

    Angular4.0中引入laydate.js日期插件的方法教程

    在AngularJs中我们会不可避免的使用第三方库,例如jquery插件库。下面这篇文章主要给大家介绍了关于Angular4.0中引入laydate.js日期插件的相关资料,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧。
    2017-12-12
  • AngularJS中filter的使用实例详解

    AngularJS中filter的使用实例详解

    这篇文章主要介绍了AngularJS中filter的使用实例详解的相关资料,这里提供实例帮助大家理解掌握,希望能帮助到大家,需要的朋友可以参考下
    2017-08-08
  • AngularJS表格样式简单设置方法示例

    AngularJS表格样式简单设置方法示例

    这篇文章主要介绍了AngularJS表格样式简单设置方法,结合实例形式分析了AngularJS结合bootstrap针对表格样式的相关设置技巧,需要的朋友可以参考下
    2017-03-03
  • 简述AngularJS相关的一些编程思想

    简述AngularJS相关的一些编程思想

    这篇文章主要介绍了AngularJS相关的一些编程思想,AngularJS是一款热门的JavaScript库,推荐!需要的朋友可以参考下
    2015-06-06
  • angular4应用中输入的最小值和最大值的方法

    angular4应用中输入的最小值和最大值的方法

    这篇文章主要介绍了angular4应用中输入的最小值和最大值的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2019-05-05
  • Angular Universal服务器端渲染避免 window is not defined错误消息

    Angular Universal服务器端渲染避免 window is not&

    这篇文章主要介绍了Angular Universal服务器端渲染避免 window is not defined错误消息,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-07-07

最新评论