Reputation: 95
I have just added @grpc/grpc-js with npm i @grpc/grpc-js
into my project. When I try to use it, I get no compile time errors. However, I get runtime errors like this:
./node_modules/.pnpm/@[email protected]/node_modules/@grpc/grpc-js/build/src/channel-credentials.js:20:0
Module not found: Can't resolve 'tls'
Import trace for requested module:
./node_modules/.pnpm/@[email protected]/node_modules/@grpc/grpc-js/build/src/index.js
./pages/proto/index.tsx
https://nextjs.org/docs/messages/module-not-found
tls isn't the only one, http2, net, dns, fs, and others are also not found. I don't know why, I don't know how to fix this other than using npm i <missing module>
but this seems ridiculous. I can't find any information about these errors, and I wonder if I'm doing something wrong? Can someone help me out with this?
Upvotes: 1
Views: 1824
Reputation: 190976
@grpc/grpc-js
is only for Node. It looks like you are attempting to use it inside of a front-end web app (i.e. running in a browser), which is not supported. tls
is an internal Node package.
Upvotes: 1