zoukankan      html  css  js  c++  java
  • [Now] Deploy a Node project with Zeit’s Now

    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.

  • 相关阅读:
    Visual Detection of Lintel-Occluded Doors from a Single Image
    Linux下快速构建Android编译环境
    How to Train YOLOv4 on a Custom Dataset
    yolo v4 darknet colab
    Deep Image Matting
    给 MSYS2 添加中科大的源
    msys2 mingw64 ffmpeg 搭建最新ffmpeg编译环境 可用 ffmpeg 4.1 及更新版本
    GB28181对接摄像机/NVR视频流
    video.js在iframe中如何解决无法自动播放问题
    LiveGBS-摄像机网页低延时无插件直播实现
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6136120.html
Copyright © 2011-2022 走看看