Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preview script not working #178

Closed
schaschko opened this issue Jan 27, 2024 · 2 comments
Closed

preview script not working #178

schaschko opened this issue Jan 27, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@schaschko
Copy link

schaschko commented Jan 27, 2024

Check:

pnpm create @batijs/app --react --tailwindcss --authjs --express --eslint --prettier
cd my-app/
pnpm install

Output excerpt:

 WARN  6 deprecated subdependencies found: @babel/plugin-proposal-class-properties@7.18.6, @babel/plugin-proposal-nullish-coalescing-operator@7.18.6, @babel/plugin-proposal-numeric-separator@7.18.6, @babel/plugin-proposal-optional-chaining@7.21.0, @babel/plugin-proposal-private-methods@7.18.6, @babel/plugin-proposal-private-property-in-object@7.21.11

Then

pnpm preview

and

curl localhost:3000

Output excerpt:

Server listening on http://localhost:3000
Error: [@brillout/vite-plugin-server-entry@0.4.3][Wrong Usage] Cannot find server entry. (Re-)build your app and try again. If you still get this error, then you may need to manually import the server entry, see https://github.com/brillout/vite-plugin-server-entry#manual-import
    at importServerEntry (/home/fl/tmp/my-app/node_modules/.pnpm/@brillout+vite-plugin-server-entry@0.4.3/node_modules/@brillout/vite-plugin-server-entry/dist/importServerEntry/index.js:51:29)
    at async loadImportBuild (file:///home/fl/tmp/my-app/node_modules/.pnpm/vike@0.4.160_vite@5.0.12/node_modules/vike/dist/esm/node/runtime/globalContext/loadImportBuild.js:13:9)
    at async initGlobalContext (file:///home/fl/tmp/my-app/node_modules/.pnpm/vike@0.4.160_vite@5.0.12/node_modules/vike/dist/esm/node/runtime/globalContext.js:75:30)
    at async renderPageAndPrepare (file:///home/fl/tmp/my-app/node_modules/.pnpm/vike@0.4.160_vite@5.0.12/node_modules/vike/dist/esm/node/runtime/renderPage.js:66:9)
    at async renderPage_wrapper (file:///home/fl/tmp/my-app/node_modules/.pnpm/vike@0.4.160_vite@5.0.12/node_modules/vike/dist/esm/node/runtime/renderPage.js:26:24)
    at async renderPage (file:///home/fl/tmp/my-app/node_modules/.pnpm/vike@0.4.160_vite@5.0.12/node_modules/vike/dist/esm/node/runtime/renderPage.js:46:50)
    at <anonymous> (/home/fl/tmp/my-app/express-entry.ts:75:25)

Can you please take a look into this?

If the preview script NODE_ENV=production tsx ./express-entry.ts would work, is it also suited to run in production? In VPS this is "server:prod": "cross-env NODE_ENV=production npm run server", is there any advantage using the former?

@schaschko schaschko added the bug Something isn't working label Jan 27, 2024
@magne4000
Copy link
Member

Have you ran pnpm run build beforehand? The "preview" wording comes from Vite, which is designed to run what's in your dist folder.

If the preview script NODE_ENV=production tsx ./express-entry.ts would work, is it also suited to run in production

Yes and no, depends where you deploy it. If you deploy it on a server (as opposed to serverless), it should be ok.

In VPS this is "server:prod": "cross-env NODE_ENV=production npm run server", is there any advantage using the former?

I do not remember what preivous server script did, but I think it was the same thing yes.

@schaschko
Copy link
Author

Running pnpm run build beforehand solves it, thanks a lot!

Just looked it up, it was node --loader ts-node/esm ./server/index.ts. Found something here about ts-node vs. tsx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants