node.js - 构建(准备)用于生产(部署)的 Node.js 应用程序

标签 node.js web-applications nodejitsu

我有一个由多个 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/

相关文章:

node.js - Twilio 函数 : Sending WhatsApp message when incoming call is received

javascript - 前端监听器监听后端监听器

node.js - 使用 typeorm 在 postgres 中搜索数组中的项目

web-applications - Firefox 和 Chrome 应用 list 的主要区别是什么

node.js - 我应该使用来自服务提供商或heroku 插件的elasticsearch 还是我自己设置的elasticsearch?

javascript - 使用 PhantomJS 将多个页面渲染为 pdf 文件

security - 如何在现有 Web 应用程序中逐步淘汰密码哈希算法?

javascript - 如何自定义iframe右键弹窗

node.js - 使用 Nodejitsu 部署时出现构建快照错误

node.js - 将私有(private)存储库部署为依赖项