主Node.js文件存在哪些命名约定? [英] What naming conventions exist for the primary Node.js file?

查看:82
本文介绍了主Node.js文件存在哪些命名约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题已被完全编辑,希望可以重新打开.

主Node.js文件的命名留给用户使用,似乎没有任何公认的约定来定义.为了希望找到一个好名字,我很好奇Node.js生态系统的其他部分是否有命名约定可能会建议使用一个名字.

The naming of the main Node.js file is something left to the user and and does not seem to be defined by any well established convention. In hopes of finding a good name, I am curious if there are naming conventions in other parts of the Node.js ecosystem that might suggest a name to use.

我见过的一些名字是:app.jsindex.jsmain.jsserver.js

Some names I have seen are: app.js, index.js, main.js, server.js, etc.

请在答案中仅提供详细记录的标准.

Please provide only well documented standards in answers.

推荐答案

NPM似乎提出了一种标准,使人们可以像这样在package.json文件中定义主文件:

NPM seems to suggest a standard whereby one can define the primary file in the package.json file like so:

"scripts": {"start": "node server.js"}

如果未设置此类属性,则NPM在包的根目录中查找server.js文件.如果server.js存在,它将与Node一起运行.

If no such property is set, NPM looks for a server.js file in the root of the package. If server.js exists, it will be run with Node.

此默认值似乎强烈建议名称server.js应该是标准名称.

This default seems to be a strong suggestion that the name server.js should be the standard.

这篇关于主Node.js文件存在哪些命名约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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