Use Zeit’s now to deploy a node application from your local machine to a remote cloud service in moments.

Install:

npm i -g now

Deploy:

now

The url it generates contains two part, the first part is the application name, and the second part is generated according to your application current state (code) and package.json. If you deploy this package against this code, using now, that's the URL that you get. I can show you that that's true by running ZEIT now again.

If I run Now again, we're not going to see it do npm install and npm run build and npm start, it's actually just going to give us the same URL again. This is using a certain property of immutable data structures.

It's actually saying that this deployed instance is like a pure function of this particular named project with the current state of this code. No matter how many times I deploy the current state, it's always going to return the same deployment instance that I can get to via that URL.

If code changed, when we deploy again, it will genrate a new url, but the old one is still available!.

Now offers a nice little escape hatch here. If we define a script called start, and a script called now start, then when we've run it on Now, it'll ignore start and it'll run now start. The same for build, if we define a now build, echo now build step went here.

  "scripts": {
"start": "node index.js", // run this in local
"now-start": "node index.js", // in server, will run this instead of "start"
"build": "echo 'BUILD STEP GOES HERE'", // run in local
"now-build": "echo 'NOW BUILD STEP WENT HERE!'", // run in server
"test": "echo \"Error: no test specified\" && exit 1"
},

If you want your dev to run with certain environment variables, for instance, and your prod to run with other ones or something like that, we can dig a little bit more deeper into that in future lessons. There is an escape hatch, and there is a way for you to have Now specific start in build scripts.

[Now] Deploy a Node project with Zeit’s Now的更多相关文章

  1. [NodeJS] Deploy a Node Application with the Now CLI

    Now offers a friction-free way to deploy node applications right from the terminal. In this lesson, ...

  2. Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project Resource: Cannot invoke Tomcat manager: Connection refused: connect -> [Help 1]

    1.问题描述 在 DOS 下执行 tomcat7-maven-plugin 插件部署,启动 Apache Tomcat 服务报错如下: D:\2018\code\XXX>mvn tomcat7: ...

  3. MyEclipse中点击Deploy MyEclipse J2EE Project to Server无响应解决方法

    问题: MyEclipse中点击Deploy MyEclipse J2EE Project to Server无响应 解决方法: 如果工作空间的问题,那么需要删除你工作空间的一个文件就可以解决了.这个 ...

  4. 【maven】【idea】使用idea的maven进行deploy操作失败,报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project proengine-db-sdk: Failed to deploy artifacts 错误码401

    使用idea的maven进行deploy操作失败,报错: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:- f ...

  5. use MSBuild cmd to build and deploy the database project.

    You can use the below command to implement it. SET TargetDBName="Database name" SET DataBa ...

  6. [Docker] Running Multiple Containers for an Angular, Node project

    The code is from Plusight course, github link is here. In this post, we will give a overview about h ...

  7. MyEclipse中点击部署项目无响应(Deploy MyEclipse J2EE Project to Server)

    大部分情况下,只要找到当前的工作空间,删除其中一个文件就可以. 这个文件在Myeclipse工作.metadata\.plugins\org.eclipse.core.runtime\.setting ...

  8. deploy myeclipse j2ee project to server 按了没反应 怎么办

    解决办法: 1.如果工作空间的问题,那么需要删除你工作空间的一个文件就可以解决了. 这个文件在Myeclipse工作区(workspace) .metadata\.plugins\org.eclips ...

  9. tomcat7:deploy (default-cli) on project myproject: Cannot invoke Tomcat manager: Software caused connection abort: socket write error

    我使用的默认settings.xml,默认的里面只有tomcat6的服务器,没有tomcat7的服务器,接着往下看,下面来验证我的言论 进行tomcat7:run的命令时

随机推荐

  1. 【原创】k8s源代码分析-----EndpointController

    转自本人空间 http://user.qzone.qq.com/29185807/blog/1459325937 一.controller manager创建endpointController 代码 ...

  2. python核心编程五——映像和集合

    1.字典 不同意一个键相应多个值:当有键发生冲突(即.字典键反复赋值),取最后(近期)的赋值. >>> dict1 = {' foo':789, 'foo': 'xyz'}     ...

  3. jquery 04

    $('div').slice(1,3).css('background','red').end().css('color','blue');  入栈原理图: <!DOCTYPE HTML> ...

  4. 63.当当网txt数据按行切割与合并

    获取文件有多少行 //获取文件有多少行 int getN(char *path) { FILE *pf = fopen(path, "r"); if (pf==NULL) { ; ...

  5. Echarts Y轴min显示奇葩问题(做此记录)

    项目需求是根据不同情况显示最大值最小值   有9-35  12-50 9-50 三种情况 前面两种可以显示出来  但是9-50的话  最小值9显示不出来  8,7等就可以显示出来 后面想到强制从最小值 ...

  6. 【问题】VUE 同一页面路由参数变化,数据不刷新

    依赖路由的params参数获取写在created生命周期里面,因为相同路由二次甚至多次加载的关系 没有达到监听,退出页面再进入另一个页面并不会运行created组件生命周期,导致数据还是第一次进入的数 ...

  7. 数组&对象

    一.遍历数组的几种方式   var arr = [1,2,3]; Array.prototype.test=function(){} arr.name='jq'   1. for  /* * inde ...

  8. JS学习笔记 - Try / Catch / Finally

    <body> <p>请输入 5 和 10 之间的一个数:</p> <input id="demo" type="text&quo ...

  9. jmeter分布式测试的坑(转)

    本文转自:https://www.cnblogs.com/lsjdddddd/p/5806077.html 有关jmeter分布式测试的环境配置,大概就是那样,但是每次想要进行jmeter分布式测试的 ...

  10. 基于Lwip协议栈中独立模式下回调函数的使用

    一.使用Lwip协议独立模式开发 最近在STM32F4上边移植了Lwip,Lwip是一个小型开源的TCP/IP协议栈,有无操作系统的支持都可以运行.我当前只测试了TCP Server功能,然后对TCP ...