gen
gen copied to clipboard
Trouble deploying with gen
Problem
Build command successfully works under macOS, not on Netlify.
Expected behavior
gen successfully deploys using build command.
Actual Behavior
gen fails with exit code 1 when deploying using Netlify
Here's the relevant portion of the deploy log from Netlify showing an apparent issue encountered with gen@L65
Deploy log
11:10:41 PM: NPM modules installed
11:10:42 PM: /opt/build/repo/node_modules/@compositor/gen/bin/cli.js:65
const create = async (dirname, opts) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
11:10:42 PM: Cached NPM modules
11:10:42 PM: Build complete: exit code: 1
11:10:42 PM: Cleaning up docker container
11:10:42 PM: Error running command: Build script returned non-zero exit code: 1
11:10:42 PM: An error occurred while building the site, skipping the deploy and cache refresh.
11:10:43 PM: Build script returned non-zero exit code: 1
11:10:43 PM: Finished processing build request in 39.073240634s
For reference, here's my package.json:
{
"name": "2018.greg.is",
"version": "0.0.1",
"description": "Primary site of Greg Gamel",
"scripts": {
"test": "which gen",
"start": "gen src -Dop 8080",
"build": "gen src -d dist"
},
"author": "Greg Gamel",
"devDependencies": {
"@compositor/gen": "^1.0.0-4"
}
}
My site structure is currently identical to the gen example dir
Again, everything works locally without error or issue. Not sure what might be the issue. Any guidance would be appreciated.
Hey @ggamel, thanks for the detailed report. At first glance it looks like an issue with node versioning. async/await is supported in Node v7.6(?) and later. What version of node is running where the Netlify build is failing?
Hey @johnotander. Thanks for the pointer. I've now solved the deploy issue. This was a fun issue to work through & solve.
For posterity, and to help anyone else who wishes to use Netlify with gen, all working steps & config are below:
gen dir setup
Follow your heart or refer to this helpful examples dir
Set locally
Inside the repo
Export your node version to .nvmrc file:
node -v > .nvmrc
Commit .nvmrc to repo and push to GitHub:
g commit -m "Add nvmrc with node version to satisfy Netlify"
Make sure you have gen installed in devDependencies:
npm i -D @compositor/gen
Add scripts to your package.json:
"scripts": {
"test": "which gen",
"start": "gen src -Dop 8080",
"build": "gen src -d dist"
}
Note: Test these scripts to make sure they fit with your gen dir setup.
Set on Netlify
Connect your fully pushed repo
- Log in to Netlify
- Pressing New site from Git
- Locate
Build & deployunderSite Settings>Deploy Settings - Set settings as below:

- Save
- Locate
Build environment variablesunderSite Settings>Deploy Settings - Set settings as below:

Push & Deploy
Everything should be set. Now verify your repo is pushed to GitHub, open Netlify, watch the deploy log, and rejoice when your deploy/build is successful.