solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

Examples are not working

Open developer2346 opened this issue 2 years ago • 6 comments

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

developer2346 avatar Oct 20 '22 12:10 developer2346

It should be working now, could you try again?

nksaraf avatar Oct 31 '22 21:10 nksaraf

I think this can be closed

boehs avatar Nov 10 '22 03:11 boehs

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 avatar Nov 10 '22 09:11 Maxximus007

@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

yaikohi avatar Nov 18 '22 15:11 yaikohi

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)
  })
}

cbetori avatar Nov 19 '22 22:11 cbetori

The error seems to be with the useUser file being .js/.ts and not a .jsx/.tsx file.

cbetori avatar Nov 20 '22 03:11 cbetori