Use Zeit's to now
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, the first part of the application name, and the second part are 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's you get. I can show you so that's true by running ZEIT now again.
If I Run now again, we ' re not going-see it does NPM install and NPM run Build and NPM start, it's actually just going to Give us the same URL again. This is the using a certain property of immutable data structures.
It's actually saying that this deployed instance was like a pure function of this particular named project with the current State of the 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 g The ET to via URL.
If code changed, when we deploy again, it'll 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 have run it on now, it ' ll ignore start and I T ' 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, would 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 some Thing like this, we can dig a little bit more deeper to that in the future lessons. There is an escape hatch, and there is a-a-a-to-have-now-specific start in build scripts.
[Now] Deploy a Node project with Zeit ' s now