Javascript 什么是 npm init 中的“入口点”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32800066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is "entry point" in npm init
提问by Ahmed Farahat
I have an empty new project, when i run npm init i got a list of questions to answer, for example:
我有一个空的新项目,当我运行 npm init 时,我得到了一个要回答的问题列表,例如:
name: (karma)
version: (1.0.0)
description:my project description
entry point: (index.js)
I am really confused about the one that says "entry point", Should this be my index.html file or my app.js or is it something else?
我真的对说“入口点”的那个感到困惑,这应该是我的 index.html 文件还是我的 app.js 还是别的什么?
采纳答案by leeor
Quoting from this blog post:
引自这篇博文:
Entry pointis the javascript file that will be invoked when consumers of your module “require” it, this file will include the main logic for your module, or if it is a large module you can export public functions found with other files (typically in the lib directory)
入口点是当你的模块的消费者“需要”它时将被调用的 javascript 文件,这个文件将包含你模块的主要逻辑,或者如果它是一个大模块,你可以导出其他文件中找到的公共函数(通常在lib目录)
So it should be your app.js
file.
所以它应该是你的app.js
文件。
回答by Malatesh Patil
For any project, entry point is the file from which execution starts. It depends on project configuration and run time environment of the technology we are using.
对于任何项目,入口点是执行开始的文件。这取决于我们使用的技术的项目配置和运行时环境。
Examples : For a node.js project app.jsis used initializes the app and glues everything together.
示例:对于 node.js 项目app.js用于初始化应用程序并将所有内容粘合在一起。
回答by Lamech Desai
Entry point is the path that your users will access using the index.js to be able to access the full view and services of your module I will rather leave it the way it is if you do not know what you are doing.
入口点是您的用户将使用 index.js 访问的路径,以便能够访问模块的完整视图和服务,如果您不知道自己在做什么,我宁愿保持原样。