有没有一种方法可以自动为Node.js项目构建package.json文件 [英] Is there a way to automatically build the package.json file for Node.js projects
问题描述
package.json是否应该手动编辑?像npm这样的程序难道不只是浏览文件,查看"require"语句,然后使用该程序将必要的条目放入package.json文件中吗?有这样的程序吗?
Is package.json supposed to be manually edited? Couldn't a program like npm just look through the files, see the "require" statements, and then use that to put the necessary entries in the package.json file? Are there any programs like that?
推荐答案
npm 使用package.json文件了解您的node.js项目.
The package.json file is used by npm to learn about your node.js project.
使用npm init
为您生成package.json文件!
Use npm init
to generate package.json files for you!
它与npm捆绑在一起.在此处阅读其文档: https://docs.npmjs.com/cli/init
It comes bundled with npm. Read its documentation here: https://docs.npmjs.com/cli/init
此外,还有一个官方工具可用于以编程方式生成此文件: https://github .com/npm/init-package-json
Also, there's an official tool you can use to generate this file programmatically: https://github.com/npm/init-package-json
这篇关于有没有一种方法可以自动为Node.js项目构建package.json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!