Command line ✎
Make sure you write a script like the shown below, e.g. app.js
// require and create a Grown-container
const Grown = require('grown')();
// create the web-server instance
const server = new Grown();
// exports the server to be used later
module.exports = server;
// starts if required directly by node
if (require.main === module) {
server.listen(Grown.argv.flags.port || 8080);
}
Run your server manually with
node appor withnpx grown server start— the latter will check for any{app,main,index,server}.jsscript.
Try npx grown --help to get more usage info, also in sub commands like npx grown generate def --help and so on.
Also, you can setup a
bin/grownexecutable with the following content:#!/usr/bin/env node require('grown/cli.js');Test it out!
Highlights
- The application script can be named as
app.js,main.js,index.jsorserver.js— otherwise, it should be specified by the--appoption. - The application script can be invoked by the
grownbinary if the server gets exported — it can be executed bynodeusing therequire.maincheck.