Server component throws error with module not found
Unanswered
Tricolored Heron posted this in #help-forum
Tricolored HeronOP
Hi,
I've been trying for hours to debug this issue where I'm converting regular client pages into server components, but getting an error saying that "Module 'fs' could not be found" (and others).
The weird thing is, I've done 4 other pages in the exact same way, but this one for some reason fails.
This is the import trace I'm getting:
This is my page code:
This is the page implementation that gets imported:
Continued in comment...
I've been trying for hours to debug this issue where I'm converting regular client pages into server components, but getting an error saying that "Module 'fs' could not be found" (and others).
The weird thing is, I've done 4 other pages in the exact same way, but this one for some reason fails.
This is the import trace I'm getting:
client.js:1 ../../node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
Import trace for requested module:
../../node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
../../node_modules/@mapbox/node-pre-gyp/lib/ sync ^\.\/.*$
../../node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
../../node_modules/bcrypt/bcrypt.js
../../libs/api/feature-auth/src/lib/signin.ts
../../libs/api/feature-auth/src/index.ts
../../libs/web/util-auth/src/lib/auth-options.ts
../../libs/web/util-auth/src/index.ts
../../libs/web/feature-scene-snapshot/src/lib/snapshot.tsx
../../libs/web/feature-scene-snapshot/src/index.ts
../../libs/web/data-access-session-user/src/lib/session-user-store.ts
../../libs/web/data-access-session-user/src/index.ts
./app/providers.tsxThis is my page code:
export default async function ScenePage({
params,
}: {
params: { filter: string };
}) {
return (
<>
<SceneSnapshot />
</>
);
}This is the page implementation that gets imported:
import { getServerSession } from '@groovehub/web/util-auth';
export async function SceneSnapshot() {
const { sessionUser } = await getServerSession();
return <div>Hi there</div>;
}Continued in comment...
1 Reply
Tricolored HeronOP
As soon as I add the
However, strangely enough, if I add the
Has anyone got any ideas how to debug this?
getServerSession import, it crashes BUT the exact same thing works on other pages... I've tried removing everything else other than this import (from that page level onwards) but no luck.However, strangely enough, if I add the
getServerSession import into the actual ScenePage it works.Has anyone got any ideas how to debug this?