Missing Modules, only on client.
Unanswered
Pyramid ant posted this in #help-forum
Pyramid antOP
Trying to set 'tls' and 'net' 'empty' on the client through webpack, and config.node doesn't exist on next 13.
in next.config.js I added:
redis is trying to find 'tls' and 'net', and I think this might be a solution.
Thank you
in next.config.js I added:
webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `tls,net` module
console.log(isServer);
if (!isServer) {
console.log(config);
config.node = {
tls: 'empty',
net: 'empty'
}
}
return config
} redis is trying to find 'tls' and 'net', and I think this might be a solution.
Thank you
21 Replies
@Pyramid ant Trying to set 'tls' and 'net' 'empty' on the client through webpack, and config.node doesn't exist on next 13.
in next.config.js I added:
webpack: (config, { isServer }) => {
// Fixes npm packages that depend on `tls,net` module
console.log(isServer);
if (!isServer) {
console.log(config);
config.node = {
tls: 'empty',
net: 'empty'
}
}
return config
}
redis is trying to find 'tls' and 'net', and I think this might be a solution.
Thank you
Im a little confused - are you trying to pass node modules to the browser?
Pyramid antOP
I'm having errors saying 'tls' and 'net' modules are missing.
and I believe it's the client trying to find these modules
Pyramid antOP
Sorry it's an image
Just wondering what the new way to set a node to be empty.
You're trying to use redis client on the frontend?
Pyramid antOP
I can fetch in page.tsx, it's when I fetch from anywhere it else brings up this error.
yes
@Pyramid ant yes
You can't do that, it's a server-side package
Pyramid antOP
well, I can from page.tsx
@Pyramid ant well, I can from page.tsx
right, because that runs on the server
Pyramid antOP
So components that page.tsx calls isn't running on the server?
@Pyramid ant So components that page.tsx calls isn't running on the server?
not if you mark it as 'use client';
Pyramid antOP
It is not 'use client'
But, thanks for the feedback, it's giving me some food for though
@Pyramid ant But, thanks for the feedback, it's giving me some food for though
If you provide some more code and what you're trying to accomplish I can help more. Redis can only be used for KV storage by default in next, since serverless runtimes don't support websockets. If you're trying to do something that's real-time, WebRTC and a dedicated microservice are the recommended pattern.
Pyramid antOP
I believe we have that setup with a dedicated service via docker, just trying a lot of different solutions. and thinking it's webpack issues.
@Pyramid ant I believe we have that setup with a dedicated service via docker, just trying a lot of different solutions. and thinking it's webpack issues.
If you have a dedicated service already, you can just proxy the URL in your next config and connect from the client with something like socket.io or [webrtc](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) directly from the client
Pyramid antOP
I connect too, it's just one component level down from page.tsx in a server component brings up the error.