Skip to content
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

Uncached or missing npm package: "@types/node" when import mapping a node: specifier #805

Closed
shinebayar-g opened this issue Feb 9, 2023 · 8 comments · Fixed by denoland/deno#19956
Labels
bug Something isn't working dx

Comments

@shinebayar-g
Copy link

shinebayar-g commented Feb 9, 2023

Describe the bug

Below code works when I do deno run example.ts. However vscode extension is giving error if I use deno.json & import maps.

Uncached or missing npm package: "@types/node".deno(no-cache-npm)

To Reproduce

  1. deno.json
{
    "imports": {
        "fs": "node:fs"
    }
}
  1. example.ts.
import * as fs from 'fs';

function getTeams() {
    const teams = fs.readdirSync('./teams');
    console.log(teams);
}

getTeams();

Expected behavior

Import map works as expected.

However, when I do import * as fs from 'node:fs'; it works.

Screenshots

image

image

Versions

❯ deno --version
deno 1.30.3 (release, aarch64-apple-darwin)
v8 10.9.194.5
typescript 4.9.4

Deno extension: v3.17.0
VSCode: Version: 1.75.0 (Universal)
Commit: e2816fe719a4026ffa1ee0189dc89bdfdbafb164
Date: 2023-02-01T15:24:42.903Z
Electron: 19.1.9
Chromium: 102.0.5005.194
Node.js: 16.14.2
V8: 10.2.154.23-electron.0
OS: Darwin arm64 22.3.0
Sandboxed: No

@Creative-Difficulty
Copy link

Any updates?

@bartlomieju
Copy link
Member

@shinebayar-g @Creative-Difficulty sorry for a slow response. Do you still experience these problems with Deno v1.35? We fixed two big pain points around npm and import maps in that release and I'm wondering if the issue still persists.

@bartlomieju bartlomieju added needs info maybe fix available Might have been fixed already dx labels Jul 10, 2023
@Creative-Difficulty
Copy link

Will test it out!

@osddeitf
Copy link

@bartlomieju I think it still doesn't work
image
If I remember correctly, it worked alright after node: prefix stabilized (without installing @types/node), and the location of node: packages type definitions were not .cache/deno/npm/registry.npmjs.org/@types/node.

@bartlomieju
Copy link
Member

@dsherret can you advise here? I thought this would work out-of-the box now.

@reggi
Copy link

reggi commented Jul 26, 2023

This recently just broke for me without import maps 😭

deno 1.35.2 (release, aarch64-apple-darwin)
v8 11.6.189.7
typescript 5.1.6

(Deno VSCODE v3.19.1)

Screen Shot 2023-07-26 at 3 22 31 PM

@dsherret
Copy link
Member

@reggi what happens why you cache it by using the quick fix or the Deno: Cache Dependencies command? If that doesn't work, maybe try deno cache your_file.ts then run Deno: Restart Language Server

@reggi
Copy link

reggi commented Jul 26, 2023

@dsherret thanks a bunch!
running deno cache then restarting didn't do it ❌
using the quick fix solution worked ✅

@dsherret dsherret added bug Something isn't working and removed maybe fix available Might have been fixed already needs info labels Jul 26, 2023
@dsherret dsherret changed the title Uncached or missing npm package: "@types/node".deno(no-cache-npm) Uncached or missing npm package: "@types/node" when import mapping a node: specifier Jul 26, 2023
dsherret added a commit to denoland/deno that referenced this issue Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dx
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants