question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Impossible to build/run a production build

See original GitHub issue

How to reproduce

keystone build
keystone start

Expected behavior

The app is built into a production-ready output dir (ex : dist) and keystone start runs that build.

Actual behavior

keystone build does not appear to output any content that keystone dev does not.

$ keystone build
✨ Building Keystone
✨ Generating Admin UI code
✨ Generating Keystone config code
✨ Building Admin UI
info  - Skipping validation of types  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data  
info  - Generating static pages (18/18)
info  - Finalizing page optimization  

Page                                       Size     First Load JS
β”Œ β—‹ /                                      1.74 kB         444 kB
β”œ   /_app                                  0 B             442 kB
β”œ β—‹ /404                                   194 B           442 kB
β”œ Ξ» /api/__keystone_api_build              0 B             442 kB
β”œ β—‹ /deliveries                            257 B           451 kB
β”œ β—‹ /deliveries/[id]                       3.72 kB         446 kB
β”œ β—‹ /environments                          257 B           451 kB
β”œ β—‹ /environments/[id]                     3.72 kB         446 kB
β”œ β—‹ /init                                  6.17 kB         448 kB
β”œ β—‹ /licenses                              253 B           451 kB
β”œ β—‹ /licenses/[id]                         3.72 kB         446 kB
β”œ β—‹ /no-access                             425 B           443 kB
β”œ β—‹ /organizations                         256 B           451 kB
β”œ β—‹ /organizations/[id]                    3.72 kB         446 kB
β”œ β—‹ /projects                              255 B           451 kB
β”œ β—‹ /projects/[id]                         3.72 kB         446 kB
β”œ β—‹ /signin                                1.6 kB          444 kB
β”œ β—‹ /users                                 251 B           451 kB
β”” β—‹ /users/[id]                            3.72 kB         446 kB
+ First Load JS shared by all              442 kB
  β”œ chunks/framework-b6621d06fb4f3aa0.js   42 kB
  β”œ chunks/main-8f3915d3027d012d.js        26.9 kB
  β”œ chunks/pages/_app-9ae8491b0b0789f0.js  373 kB
  β”” chunks/webpack-5752944655d749a0.js     840 B

Ξ»  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
β—‹  (Static)  automatically rendered as static HTML (uses no initial props)

Done in 17.24s.

Plus keystone start fails anyway:

✨ Starting Keystone
ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization
    at Object.Z (/app/.keystone/admin/.next/server/pages/api/__keystone_api_build.js:199:36)
    at Module.config (/app/.keystone/admin/.next/server/pages/api/__keystone_api_build.js:49:100)
    at Object.start (/app/node_modules/@keystone-6/core/scripts/dist/keystone-6-core-scripts.cjs.dev.js:464:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Environment

NodeJS version 16

  "dependencies": {
    "@keystone-6/auth": "^1.0.2",
    "@keystone-6/core": "^1.0.1",
    "@keystone-6/fields-document": "^1.0.1",
    "typescript": "^4.5.4",
}

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dcousenscommented, Mar 31, 2022

(I deleted a duplicate comment) This is interesting to follow along @JMLX42! Please keep us updated, as soon as you have a reproduction we can try and action this.

1reaction
JMLX42commented, Mar 30, 2022

The same error finally popped again after editing nothing but auth.js to set process.env.SESSION_SECURE == "true".

diff --git a/app/auth.ts b/app/auth.ts
index 48569a6..8733f8f 100644
--- a/app/auth.ts
+++ b/app/auth.ts
@@ -53,6 +53,7 @@ let sessionMaxAge = 60 * 60 * 24 * 30; // 30 days
 const session = statelessSessions({
   maxAge: sessionMaxAge,
   secret: sessionSecret!,
+  secure: process.env.SESSION_SECURE == "true",
 });
smartshape-license-manager-app-1          | $ keystone start
smartshape-license-manager-app-1          | ✨ Starting Keystone
smartshape-license-manager-app-1          | ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization
smartshape-license-manager-app-1          |     at Object.Z (/srv/app/.keystone/admin/.next/server/pages/api/__keystone_api_build.js:200:36)
smartshape-license-manager-app-1          |     at Module.config (/srv/app/.keystone/admin/.next/server/pages/api/__keystone_api_build.js:49:100)
smartshape-license-manager-app-1          |     at Object.start (/srv/app/node_modules/@keystone-6/core/scripts/dist/keystone-6-core-scripts.cjs.dev.js:464:65)
smartshape-license-manager-app-1          |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
smartshape-license-manager-app-1          | error Command failed with exit code 1.
smartshape-license-manager-app-1          | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So if there is any circular dependency issue, it is most likely not in my code.

I think the problem is trying to build/run a production build with NODE_ENV not actually set to "production".

Read more comments on GitHub >

github_iconTop Results From Across the Web

React production build failed to load - Stack Overflow
I have built some code with React. During its "development build", npm start at localhost:3000 give me the correct behavior.
Read more >
Building for Production - Vite
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >
10 best practices to containerize Node.js web applications ...
The following article provides production-grade guidelines for building optimized and secure Node.js Docker images.
Read more >
Multi-stage builds - Docker Documentation
$ docker build -t alexellis2/href-counter:latest . The end result is the same tiny production image as before, with a significant reduction in complexity....
Read more >
Troubleshooting build errors and crashes - Expo Documentation
If your native toolchains are installed correctly and you are unable to build and run your project in release mode on your local...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found