npm specifier not found in LSP only, and so no types for certain imports
It seems to be unfixable (via cache reload, deno info, reboot, rm -rf ~/.cache/deno, ext.), so right now the LSP is unusable and I'm writing JS with no types.
deno run
, deno check
, deno info
and deno cache --reload
, all run without error and don't complain about the missing specifier like in the LSP.
e.g. importing drizzle-orm
and no types are available. output I see when I run cache and it's dependencies:
but before I saw:
so it seems to be random?
I also tried downgrading deno to 1.42.4 and explicitly caching missing packages via the cli and via adding them to deno.json. nothing worked, lsp remains unusable.
anyone has any idea?7 Replies
Happens on other projects too. So it's something corrupt or npm is down?
I apologize for the inconvenience, but I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it seems like there might be an issue with the Language Server Protocol (LSP) not being able to find or use the npm specifiers for type definitions.
While I cannot provide a solution based on the Deno documentation, I can suggest a couple of things to check based on the error messages you've shared:
1. Ensure that the import statements in your code are correct and that the packages you are trying to import actually have type definitions available. Sometimes, npm packages might not have types included, and you might need to install them separately or provide your own type definitions.
2. Check if the
--cached-only
flag is being set somewhere in your configuration or command line arguments unintentionally. This flag tells Deno to only use the cache and not to fetch any remote dependencies, which could be why the LSP is unable to find the npm specifiers.
3. Since you mentioned that downgrading Deno and explicitly caching the packages did not resolve the issue, it might be worth checking if there's an issue with the LSP configuration or if there are any known issues with the version of the LSP you are using.
Please note that this advice is not based on the Deno documentation, and I recommend double-checking the accuracy of the advice given. If the issue persists, you may want to consider reaching out to the Deno community or filing an issue on the Deno GitHub repository for further assistance.unhelpful
It seems the LSP is unable to resolve something that needs "@types/node" and than bails out. for some reason
deno cache
has no problem
is there any reccomendation about how to debug it further?Try deleting the lockfile if you have one
yes, thanks! I didn't have a lock file, but had "lock:false" in deno.json. changing to lock:true fixes the issue. deleting the lock file and changing back to lock:false and the problem returns. it does seem like a bug
btw this still appears in the lsp output view
filed a bug here: https://github.com/denoland/deno/issues/23734
GitHub
"Could not set npm package requirements" when lock:false in deno.js...
Version: Deno 1.43.1 In my project I have deno.json with lock: false. Some dependencies fail to cache with Could not set npm package requirements. Error getting a response at https://registry.npmjs...