solid-start
solid-start copied to clipboard
Examples are not working
Just wanted to run one of the examples but receive error on production mode.
Commands ran:
npm run build
npm run start
Result:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/usr/testExample/dist/server.js' imported from /usr/testExample/node_modules/solid-start-node/index.js
Tried on /examples/bare
, /examples/with-tailwindcss
and some more
It should be working now, could you try again?
I think this can be closed
with-prisma doesn't work: Pls add
ssr: { external: ['@prisma/client'], },
in vite.config.ts.
After that it works, but still this console msg: Uncaught Error: PrismaClient is unable to be run in the browser.
@Maxximus007 oh my god that fixed my issue with building my application. Thank you!
The error message I got was really different from OP though and had me looking into different 'problems'. I'll share my error for others that might get it as well.
(Node version 16.18 with pnpm)
I got these warnings in pnpm build
:
(...)
solid-start server built in: 934.499ms
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
This was the error I got after pnpm start
:
file:///home/<USER>/<PROJECTROOT>/dist/server.js:40386
import_path.default.join(__dirname, "../query-engine-darwin");
^
ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/home/<USER>/<PROJECTROOT>/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///home/<USER>/<PROJECTROOT>/dist/server.js:40386:27
at file:///home/<USER>/<PROJECTROOT>/dist/server.js:51839:3
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
After adding // ssr: { external: ['@prisma/client'], },
it works perfectly
Just setup solid-start with Prisma and I am getting Uncaught Error: PrismaClient is unable to be run in the browser.
this seems to also be breaking basic features like onClick
events. When I move createServerData$
out of the useUser
and wrap the the useUser
function call it fixes the uncaught error and fixes the onClick
events.
index.jsx
export function routeData() {
return createServerData$(async (_, { request }) => {
return await useUser(request)
})
}
The error seems to be with the useUser file being .js/.ts and not a .jsx/.tsx file.