raunioroo
raunioroo11mo ago

LSP complains about missing package mongodb

VS Code keeps complaining about "uncached or missing npm package: mongodb". Cache "npm:mongodb" and it's dependencies Quick fix action does not help, neither does deno cache --reload npm:mongodb. The script works flawlessly with deno run, it's just VSCode/LSP that does seem to struggle with the package. There seem to be a lot of identical related entries in the Deno LSP output: Could not set npm package requirements. Error getting response at https://registry.npmjs.org/encoding for package "encoding": An npm specifier not found in cache: "encoding", --cached-only is specified. (for example attempting to cache npm:mongodb via Quick fix makes the LSP print out these)
No description
No description
1 Reply
Deno AI Helper
Deno AI Helper11mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the message you've provided, it seems like there might be an issue with the Deno Language Server Protocol (LSP) and its integration with VS Code when it comes to handling npm packages. One thing to note is that Deno does not use npm packages directly as it has its own module system that relies on URLs. If you are trying to use an npm package within Deno, you would typically need to use a tool like denoify or find a Deno-compatible module. The error message you're seeing suggests that the LSP is trying to fetch the encoding package from the npm registry, but it's not found in the cache and the --cached-only flag is preventing it from fetching it directly. Since this advice is not based on the Deno documentation, please double-check the accuracy of this advice. It might be helpful to look into whether the mongodb package you are trying to use has a Deno-compatible version or if there's a way to configure the Deno LSP in VS Code to handle npm packages differently. Additionally, consider checking if there are any updates or bug reports related to this issue in the Deno repository or the VS Code Deno extension repository.