Hi Team, I am following this repository: <https://...
# help
p
Hi Team, I am following this repository: https://github.com/cerbos/cerbos-sdk-javascript/ to build a simple HTML, CSS, and JS application and integrate Cerbos to it. I am getting the following error in the browser console:
Uncaught TypeError: Failed to resolve module specifier "@cerbos/http". Relative references must start with either "/", "./", or "../".
On troubleshooting I got to know that it can be an issue with how the module is imported in the client-side, and npm packages sometimes throw errors when used directly in browsers. I downloaded a build tool: Webpack, built it and now in the browser console, I get
Copy code
cerbos-client.js:5 Uncaught Error: Cannot find module '@cerbos/http'
    at webpackMissingModule (cerbos-client.js:5:50)
    at eval (cerbos-client.js:5:137)
    at ./cerbos-client.js (bundle.js:19:1)
    at __webpack_require__ (bundle.js:53:41)
    at eval (index.js:2:75)
    at ./index.js (bundle.js:29:1)
    at __webpack_require__ (bundle.js:53:41)
    at bundle.js:93:37
    at bundle.js:95:12
webpackMissingModule @ cerbos-client.js:5
eval @ cerbos-client.js:5
./cerbos-client.js @ bundle.js:19
__webpack_require__ @ bundle.js:53
eval @ index.js:2
./index.js @ bundle.js:29
__webpack_require__ @ bundle.js:53
(anonymous) @ bundle.js:93
(anonymous) @ bundle.js:95
index.html:1 Uncaught TypeError: Failed to resolve module specifier "@cerbos/http". Relative references must start with either "/", "./", or "../".
I would like to understand how to connect Cerbos using cerbos/http package and can grpc also be used, because in the repository linked above, it is written that for browser-based applications, cerbos/http provides a client for interacting with Cerbos PDP
a
Hi Pratham, I suspect this means that Webpack isn't resolving the
exports
field in @cerbos/http's
package.json
correctly. Could I check what versions of Node.js, Webpack, and @cerbos/http you're using?
I just released a new version that fixes a couple of issues related to this, maybe try bumping @cerbos/http to the latest version (0.18.1) and see if that sorts it?
p
Hi Andrew, I am using:- Node.js version: 18.19.1 Webpack: ^5.91.0 @cerbos/http: 0.18.0 Ok, i will just try to update the version and see if that helps, will apprise you about the same, thank you!