vscode_deno
vscode_deno copied to clipboard
deno(no-cache-npm), even after caching
Describe the bug
import lodash from "npm:lodash";
console.log(lodash);
getting persistent red squigglies
To Reproduce
[kache@whitebox]$ code --version
1.76.0
92da9481c0904c6adfe372c12da3b7748d74bdcb
x64
[kache@whitebox scribepod2]$ deno --version
deno 1.31.1 (release, x86_64-unknown-linux-gnu) # arch btw
v8 11.0.226.13
typescript 4.9.4
extension version 3.17
- Install deno
- Attempt to
import lodash from "npm:lodash"
- run it, deno caches the package correctly under ~/.cache/deno
- squigglies still there
- tried to run cache deps from vscode, squigglies persist
- tried to reload the window, squigglies persist
- tried to explicitly define den dir in workspace settings, squigglies persist
Expected behavior I'd expect that the red squigglies not be there
I can grease these things and figure it out. I just don't know how! If you can point me in a direction where I can get the LSP output, let me know. I just need a log of where it's trying to grab the dep out of, and why it's failing out on it. Let me know!
I poked around a bit more I saw that there was an option to have the LSP logs out on some console, but I couldn't find it. What I did find though, is a process that gets spawned by vscode, which I'm pretty sure is the LSP. How do I get the logs?
Also, can I just disable the red squigglies? I don't really care that much, it just makes it hard to dev :P
Go to the Output tab (Ctrl-Shift-U) and on the right dropdown pick "Deno Language Server".
Also, I found that an package.json (just an empty JSON {}
is sufficient) is needed (otherwise the language server will pick up the "closest" package.json).
I had the same issue. I addressed the errors in the logs and this was resolved. In my case I had hosts that were failing in my .vscode/settings.json
file:
{
"deno.suggest.imports.hosts": {
"https://bad.url": true
}
Same issue here, but my error was:
Could not set npm package requirements. Error getting response at https://registry.npmjs.org/@solidjs/router for package "@solidjs/router": An npm specifier not found in cache: "@solidjs/router", --cached-only is specified.
Fixed it with deno cache npm:@solidjs/router
Same issue here. I solved it by delete deno.lock
and delete cache directory(the one shown by deno info
) and cache all the deps again. But still don't know why this happened.
In my case, I had a package.json
at the root of my repository and then I had deno.jsonc
in a subfolder. I fixed the issue by:
- Creating a
deno.jsonc
atsubdir
(no contents are needed, only{}
) - Change
deno cache subdir/main.ts
tocd subdir && deno cache main.ts
- Otherwise deno will reuse the
node_modules
from the root directory, and will potentially overwrite dependencies installed by NPM (very dangerous). - Otherwise
deno cache
will not recognize thedeno.jsonc
as well.
- Add to
.vscode/settings
"deno.config": "subdir/deno.jsonc"
Now it works.
I also built a repo for reproduction: https://github.com/felipecrs/deno-vscode-npm-bug
I left instructions in the README.
Note however that I cannot trigger this specific issue (no-cache-npm even after clicking in cache) in the reproduction environment for some reason which I cannot explain (but I have one internal repo which I can consistently reproduce the issue although I fixed by following my instructions above).
The reproduction repo however at least highlights how deno
is creating and installing dependencies at the top level node_modules
while it should not.