我有一个由多个 nod.js 后端应用程序组成的项目。这些应用程序使用相同的模块(放置在共享位置的每个 ap 文件夹之外)。它们将部署在不同的环境(服务器)上,一些代码用于测试,一些代码用于正常调试。
如果我为我的一个应用程序选择了一个平台(例如 PaaS nodejitsu),我应该如何只向那里发送我的一个应用程序的生产代码?我部署在 nodejitsu 上,它只发送应用程序文件夹并使用 package.json 来配置应用程序。但是有很多代码不需要(测试),例如,有些代码是外部的。如果我也想阻止服务器代码怎么办?这个问题应该如何解决?
对于前端应用程序来说,有大量的方法需要构建用于生产。我知道需求是不同的,但没有找到任何有关如何正确准备要部署的 Node.js 后端应用程序的最佳实践的信息。
最佳答案
阅读部分 "Keeping files out of your package" in the NPM Developer page 。它指出以下内容
Use a .npmignorefile to keep stuff out of your package. If there's no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file. If you want to include something that is excluded by your .gitignore file, you can create an empty .npmignore file to override it.
关于node.js - 构建(准备)用于生产(部署)的 Node.js 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12661779/