I think I finally drilled down the issue with SST ...
# sst
d
I think I finally drilled down the issue with SST and SEED deploy a NextJS webapp. SEED's pipeline is executing:
Copy code
====================
🛠 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...
$ npm install
34.90 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
$ npx sst build --stage develop --region eu-west-1 --verbose
But the
npx sst build
is not running
npm install
also in the NextJS sub-folder so it is missing the
next
executable and this failure appears in the log like:
Copy code
Building Next.js site frontend
Error: There was a problem building the "site" NextjsSite.
What is supposed to be the build process for SST apps based on NextjsSite?
Should I configure SEED to run
npm install
in the
frontend
folder before running
npx sst build...
?
Or am I missing something else?
j
@Davide Ungari i just added a seed.yml file with
Copy code
before_build:
  - cd frontend && npm install
  - ls -lsa node_modules/next
looks like it got past our issue. i saw the npm install run in the logs and it listed out the next package from node_modules
Not sure if this is the correct solution but it might work for now
d
Thank you, it make sense and I will do it. Anyway I'm wondering the same, if this is how should be...hopefully somebody will give us some guidance on it
j
Thanks for figuring out the root cause!
Ah mine failed again, just later in the process. Same error though. I’m going to do a clean checkout and put in some logging in NextjsSite.ts
Copy code
info  - Creating an optimized production build...
(node:698) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:698) [DEP_WEBPACK_CHUNK_ADD_MODULE] DeprecationWarning: Chunk.addModule: Use new ChunkGraph API
Error: There was a problem building the "Site" NextjsSite.
    at NextjsSite.buildApp (/tmp/seed/source/node_modules/@serverless-stack/resources/src/NextjsSite.ts:607:13)
    at new NextjsSite (/tmp/seed/source/node_modules/@serverless-stack/resources/src/NextjsSite.ts:148:16)
    at new FrontendStack (/tmp/seed/source/stacks/FrontendStack.js:9:18)
    at Object.main (/tmp/seed/source/stacks/index.js:17:3)
    at Object.<anonymous> (/tmp/seed/source/.build/run.js:94: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)
@Davide Ungari i changed my runtime from nodejs14.x to nodejs12.x in my app’s default function props and that resolved my issue. I got a clean build and deploy in Seed.
j
@Davide Ungari Just checking, are you still having this issue?
d
I solveded adding in SEED adding seed.yml:
Copy code
before_build:
  - cd frontend && npm ci
To identify the issue I had to add more details in the console.log of such exceptions, so I would suggest to add it in the library itself. If this is the way to go, maybe there should be something about it in the documentation because I have been naive for sure but my expectation was that
sst build
would have taken care of building the NextJS part as well.
@Jay thanks to check in about this 🙂
j
Glad you figured it out. @Frank do you think we can show something to help people with this?