I’m testing out using the SST Lerna Monorepo boile...
# seed
c
I’m testing out using the SST Lerna Monorepo boilerplate project with Seed CI/CD and hitting build errors. The project builds correctly locally (
yarn sst build
) but when try to do initial deploy of repo to Seed’s
dev
stage it fails with
Error: Subprocess exited with error 1
It looks like there may be some issues with building the StaticSite. Not sure if this is an issue in the example repo or something else. Any insights from the build log (in thread) of what to update to work around this? Thx
Copy code
⏳ Build v2 started...

====================

⚡️ Init

====================

INFO: Decrypting Seed secret environment variables...

0.03 s

INFO: Build system information

INFO: Build system environment

INFO: Restoring source code cache...

0.80 s

INFO: Checking for files changes in the salesinsight-hubspot service...

0.11 s

INFO: Restoring dependency cache...

====================

🛠 Compile

====================

$ cd /tmp/seed/source

INFO: before_compile hook not found. You can define it in your build spec.

INFO: Learn more about adding a build spec - seed.run/docs/adding-a-build-spec

INFO: Looking for package.json...

$ yarn

156.62 s

====================

🧪 Unit Test

====================

INFO: Unit tests are disabled. You can enable them in the app settings.

INFO: Learn more about running tests - seed.run/docs/running-tests

====================

📦 Build

====================

$ cd /tmp/seed/source

INFO: before_build hook not found. You can define it in your build spec.

INFO: Learn more about adding a build spec - seed.run/docs/adding-a-build-spec

$ yarn sst build --stage dev --verbose

4.63 s

SST: 0.43.2

CDK: 1.114.0

Using stage: dev

Preparing your SST app

Transpiling source

Linting source

Synthesizing CDK

synth {

  output: '.build/cdk.out',

  app: 'node .build/run.js',

  roleArn: undefined,

  verbose: 2,

  noColor: true

}

CDK toolkit version: 1.114.0 (build 7e41b6b)

Command line arguments: {

  _: [ 'synth' ],

  'version-reporting': false,

  versionReporting: false,

  app: 'node .build/run.js',

  a: 'node .build/run.js',

  output: '.build/cdk.out',

  o: '.build/cdk.out',

  quiet: true,

  q: true,

  color: false,

  verbose: 1,

  v: 1,

  disableVersionCheck: 'true',

  lookups: true,

  'ignore-errors': false,

  ignoreErrors: false,

  json: false,

  j: false,

  debug: false,

  ec2creds: undefined,

  i: undefined,

  'path-metadata': true,

  pathMetadata: true,

  'asset-metadata': true,

  assetMetadata: true,

  'role-arn': undefined,

  r: undefined,

  roleArn: undefined,

  staging: true,

  'no-color': false,

  noColor: false,

  fail: false,

  validation: true,

  '$0': 'node_modules/aws-cdk/bin/cdk'

}

merged settings: {

  versionReporting: false,

  pathMetadata: true,

  output: '.build/cdk.out',

  app: 'node .build/run.js',

  context: {},

  debug: false,

  assetMetadata: true,

  toolkitBucket: {},

  staging: true,

  bundlingStacks: [ '*' ],

  lookups: true

}

Toolkit stack: CDKToolkit

Setting "CDK_DEFAULT_REGION" environment variable to us-east-1

Resolving default credentials

Looking up default account ID from STS

Default account ID: 635813714697

Setting "CDK_DEFAULT_ACCOUNT" environment variable to 635813714697

context: {

  'aws:cdk:enable-path-metadata': true,

  'aws:cdk:enable-asset-metadata': true,

  'aws:cdk:disable-version-reporting': true,

  'aws:cdk:bundling-stacks': [ '*' ]

}

outdir: .build/cdk.out

env: {

  CDK_DEFAULT_REGION: 'us-east-1',

  CDK_DEFAULT_ACCOUNT: '635813714697',

  CDK_CONTEXT_JSON: '{"aws:cdk:enable-path-metadata":true,"aws:cdk:enable-asset-metadata":true,"aws:cdk:disable-version-reporting":true,"aws:cdk:bundling-stacks":["*"]}',

  CDK_OUTDIR: '.build/cdk.out',

  CDK_CLI_ASM_VERSION: '12.0.0',

  CDK_CLI_VERSION: '1.114.0'

}

[dotenv][DEBUG] did not match key and value when parsing line 1: 

[dotenv][DEBUG] did not match key and value when parsing line 1: # These variables are only available in your SST code.

[dotenv][DEBUG] did not match key and value when parsing line 2: # To apply them to your Lambda functions, checkout this doc - <https://docs.serverless-stack.com/environment-variables#environment-variables-in-lambda-functions>

[dotenv][DEBUG] did not match key and value when parsing line 3: 

[dotenv][DEBUG] did not match key and value when parsing line 5: 

Building Lambda function src/services/service1/handler.main

Building Lambda function src/services/service2/handler.main

Building static site frontend

npm WARN lifecycle The node binary used for scripts is /tmp/xfs-97815d58/node but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> frontend@0.1.0 build /tmp/seed/source/frontend

> react-scripts build

sh: 1: react-scripts: not found

npm ERR! code ELIFECYCLE

npm ERR! syscall spawn

npm ERR! file sh

npm ERR! errno ENOENT

npm ERR! frontend@0.1.0 build: `react-scripts build`

npm ERR! spawn ENOENT

npm ERR! 

npm ERR! Failed at the frontend@0.1.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:

npm ERR!     /root/.npm/_logs/2021-09-21T00_18_47_939Z-debug.log

Error: There was a problem building the "Site" StaticSite.

    at StaticSite.buildApp (/tmp/seed/source/node_modules/@serverless-stack/resources/src/StaticSite.ts:328:15)

    at new StaticSite (/tmp/seed/source/node_modules/@serverless-stack/resources/src/StaticSite.ts:134:24)

    at new WebsiteStack (/tmp/seed/source/lib/WebsiteStack.js:7:18)

    at Object.main (/tmp/seed/source/lib/index.js:13:3)

    at Object.<anonymous> (/tmp/seed/source/.build/run.js:90:16)

    at Module._compile (internal/modules/cjs/loader.js:1063:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

    at Module.load (internal/modules/cjs/loader.js:928:32)

    at Function.Module._load (internal/modules/cjs/loader.js:769:14)

    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

Error: Subprocess exited with error 1

    at ChildProcess.<anonymous> (/tmp/seed/source/node_modules/aws-cdk/lib/api/cxapp/exec.ts:122:23)

    at ChildProcess.emit (events.js:315:20)

    at ChildProcess.EventEmitter.emit (domain.js:467:12)

    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)

There was an error synthesizing your app.

ERROR: Error: Subprocess exited with error 1

Build v2 completed in 2m 44s. Used 0 build minutes.

====================

🗑 Cleanup

====================
t
If the StaticSite isn't included in yarn workspaces doing
yarn install
in the root won't install its deps
is the
frontend
folder in package.json#workspaces ?
c
It looks like it. Here’s the default settings from the example repo in the root package.json
Copy code
"workspaces": [
    "frontend",
    "src/packages/*",
    "src/services/*"
  ],
t
did you bootstrap frontend with create-react-app ?
ah the template already does that for you hm
does running
yarn sst build
locally work?
c
Yep, that builds it locally fine it seems
Ended up replacing React frontend files with a simple HTML page to finish testing pipeline, and was able to build successfully then. Not super fluent in React or yarn so not sure if it was a temporary issue on my part of if there’s something in the example repo that may trip up others as well
o
I've seen errors like this (not sure if it was the same error) if the build machine runs out of memory - maybe try running the react build with a larger box
f
Hey @Clayton, as a sanity check, you can add a
seed.yml
buildspec with a
before_build
script that checks if
node_modules/react-scripts
exists.
Like this:
Copy code
before_build:
  - ls -lsa node_modules/react-scripts
You can also manually do a yarn install inside frontend.
Copy code
before_build:
  - cd frontend && yarn
  - ls -lsa node_modules/react-scripts
Here are some more details on buildspec - https://seed.run/docs/adding-a-build-spec
Let me know what you find.
c
Great. Thanks @Frank, thanks @Omi Chowdhury
c
I ran into this error trying to use seed to deploy a basic React app created by following this tutorial: https://serverless-stack.com/examples/how-to-create-a-reactjs-app-with-serverless.html. The tip from @thdxr about adding the
frontend
folder to workspaces in package.json is what fixed it for me. (Perhaps a note to that effect should be added to the tutorial?)
f
Hey @Cendenta LLC , ah yeah that makes sense. Will mention it in the examples.