-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module '/app/server/node_modules/@bufbuild/protobuf/dist/proxy/index.js' imported from /app/server/chunks/app/server.mjs #610
Comments
Hey David, the directory is there in the published npm package. I assume that the error is raised by Node.js? If you are using an older version of Node.js, it is possible that this is a bug in the module resolution that has been fixed in a later version. So I'd try updating Node.js to a latest v18 or v20. If you set the environment variable |
Hi. Thank you for looking into this. I made a small reproduction repo showcasing my problem. https://github.com/DavidDomkar/bufbuild-protobuf-error-reproduction If you clone and do |
Interesting, I see the same issue. I'm not familiar with Nuxt, but it looks like it is using Nitro for the server. Nitro (or some dependency it uses) sees the "module" export we set, and deletes all other exports from our package. Node.js however will prefer the "import" export over "module", which is also set by our package. As a result, our package - as modified by Nitro - is broken on Node.js. It looks like Nitro is tracking the issue in nitrojs/nitro#1558. I think it would be helpful to provide them with your reproducible example. |
Thank you for looking into the details, this was very helpful. I left the comment in the linked issue, hopefully, they will look into it as it is a Nitro issue. |
Hi dear @timostamm and @daviddomkar. Checking this repo/packages, it seems there is an issue with ordering of The fix is pretty straight forward you can see sanity-io/client#318 in sentry package that finally removed this non standard condition also sanity-io/client#309 for more context and alternative. (made #611 draft) BTW just saw this lib, seems pretty awesome ❤️ |
We can't really prefer "import" over "module", as described in #611 (comment). We might be able to modify our exports as follows:
We will have to run more extensive tests before we can make this change (connectrpc/examples-es#1002 for context), but it does look reasonable. @daviddomkar, to work around the issue, you can modify your package.json scripts as follows:
This will restore the build artifacts of the package, until Nitro disregards the "module" condition for the |
I hope you revise this decision in later versions because,
This would also a good idea to at least support
Nitro does not disregards There are of course several but I'm afraid nothing is to fix particularly in Nitro other than patching incompatible/nonstandard packages or rollup behavior which I'm afraid is not a safe choice until rollup itself drops the package. (Thinking to add a safety check to automatically deoptimize packages with this situation of having |
Thank you for providing the workaround, I will use it until this is resolved another way. I can confirm that the quick fix with the node export condition works for me when I patch the package in node modules. |
Fixes #610 This adds explicit exports for node into the package.json for all published packages in Protobuf-ES. In addition, it modifies the path for the top-level import statement to use ESM instead of the proxy. For additional context, see connectrpc/connect-es#921
Fixes #305 For more details, see bufbuild/protobuf-es#610 but the long story short is that module systems in nodejs/browser continue to hurt everyone involved.
Hi. I am using Nuxt 3 for my application where I use this package. The problem is that after version 1.3.3. I started getting this error in production. From what I found, the proxy directory is missing from the build. I think this change is the cause: #566
Do you have an idea how to resolve this?
The text was updated successfully, but these errors were encountered: