何时使用“npm start",何时使用“ng serve"? [英] When to use 'npm start' and when to use 'ng serve'?

查看:35
本文介绍了何时使用“npm start",何时使用“ng serve"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ng serve 通过开发服务器为 Angular 项目提供服务

ng serve serves an Angular project via a development server

 

npm start 运行在包的start"中指定的任意命令其脚本"对象的属性.如果没有指定开始"属性在脚本"对象上,它将运行节点 server.js.

npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run node server.js.

似乎 ng serve 启动嵌入式服务器,而 npm start 启动 Node 服务器.

It seems like ng serve starts the embedded server whereas npm start starts the Node servers.

有人能解释一下吗?

推荐答案

npm start 将运行您为 scripts<的 start 命令定义的任何内容package.json 文件中的/code> 对象.

npm start will run whatever you have defined for the start command of the scripts object in your package.json file.

所以如果它看起来像这样:

So if it looks like this:

"scripts": {
  "start": "ng serve"
}

然后 npm start 将运行 ng serve.

这篇关于何时使用“npm start",何时使用“ng serve"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆