加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 为什么我们为Angular 2.0安装了Node.js?

发布时间:2020-12-17 08:06:51 所属栏目:安全 来源:网络整理
导读:我开始了Angular 2.0教程,设置工作区的第一步是安装Node.js和NPM。 为什么要为Angular 2.0安装Node.js? 我不记得这样做了1.X。 技术上,Node.js和NPM不需要做Angular2的工作。它尽管放松了事情。以下是我推测这个选择的主要原因: TypeScript:示例是.ts,
我开始了Angular 2.0教程,设置工作区的第一步是安装Node.js和NPM。

为什么要为Angular 2.0安装Node.js?

我不记得这样做了1.X。

技术上,Node.js和NPM不需要做Angular2的工作。它尽管放松了事情。以下是我推测这个选择的主要原因:

> TypeScript:示例是.ts,您需要运行一个编译器步骤来将它们导入到.js中,这可以使用Node.js和NPM轻松完成(加上它是一种轻松获取打字文件的方法);
> Web服务器:从“真实的”即时轻网络服务器为您提供的Angular SPA可以避免使用file://链接检查您的站点时遇到的一些令人讨厌的问题。

“快速入门”指南本身也在继续提及一些更具体的原因:

Here’s what these scripts do:

  • npm start – runs the compiler and a server at the same time,both in “watch mode”

  • npm run tsc – runs the TypeScript compiler once

  • npm run tsc:w – runs the TypeScript compiler in watch mode; the process keeps running,awaiting changes to TypeScript files and re-compiling when it sees them

  • npm run lite – runs the lite-server,a light-weight,static file server with excellent support for Angular apps that use routing

  • npm run typings – runs the typings tool separately

  • npm run postinstall – called by npm automatically after it successfully completes package installation. This script installs the TypeScript definition files defined in typings.json

您还可以看看the Quickstart source,并进一步深入了解需要NPM的地方。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读