`npm start`& `node app.js`,启动应用程序? [英] Difference between `npm start` & `node app.js`, when starting app?
问题描述
我使用命令 express new'filename'
安装了一个应用程序。我刚刚知道,您可以使用以下方式启动应用程序:
npm start
/ pre>
到目前为止,我已经使用了:
节点应用程序。 js
启动我的服务器。任何人都知道两者之间有什么区别?谢谢。
解决方案从手册页,npm开始:
运行包的开始脚本(如果提供了)。
如果没有指定版本,那么它将启动活动版本。
诚然,该描述完全没有帮助,这就是它所说的。至少它比socket.io更有文档。
无论如何,真正发生的是npm在你的 package.json 文件,如果您有类似
scripts:{start:coffee server.coffee}
那么它会这样做。如果npm找不到您的起始脚本,则默认为:
node server.js
< blockquote>
I have installed an application using the command
express new 'filename'
. I have just learned that you can start an application using:npm start
Thus far I have used:
node app.js
to start my server. Anyone know what the difference is between the two? Thanks.
解决方案From the man page, npm start:
runs a package's "start" script, if one was provided. If no version is specified, then it starts the "active" version.
Admittedly, that description is completely unhelpful, and that's all it says. At least it's more documented than socket.io.
Anyhow, what really happens is that npm looks in your package.json file, and if you have something like
"scripts": { "start": "coffee server.coffee" }
then it will do that. If npm can't find your start script, it defaults to:
node server.js
这篇关于`npm start`& `node app.js`,启动应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!