Necmttn | Craftgen.ai
Necmttn | Craftgen.ai•5mo ago

Can not resolve types from npm:identifier with peerDependency

can not resolve the types so no type support in vscode.
No description
No description
8 Replies
Necmttn | Craftgen.ai
Necmttn | Craftgen.aiOP•5mo ago
No description
Necmttn | Craftgen.ai
Necmttn | Craftgen.aiOP•5mo ago
i see it's peer dependecy
Deno AI Helper
Deno AI Helper•5mo ago
It seems like you're encountering issues with resolving types from an npm:identifier in Deno. According to the documentation, Deno has native support for importing npm packages using npm: specifiers, and many packages ship with types out of the box. However, there are cases where npm packages may not provide the correct types under the node16 module resolution that Deno uses, which can lead to type errors that the TypeScript compiler tsc does not report. If you're facing an issue where a default export from an npm: import appears to have a wrong type, and the right type seems to be available under the .default property, it's likely that the package provides incorrect types under node16 module resolution for imports from ESM (ECMAScript modules). Here are a few steps you can take to resolve this issue: 1. Check if the error also occurs with tsc --module node16 and "type": "module" in package.json, or consult the "Are the types wrong?" website, particularly the "node16 from ESM" row, to verify the issue. 2. If the package doesn't support TypeScript's node16 module resolution, you can: - Open an issue at the issue tracker of the package about the problem and possibly contribute a fix. - Use a CDN that rebuilds the packages for Deno support, instead of an npm: identifier. - Ignore the type errors in your codebase with // @ts-expect-error or // @ts-ignore. 3. For packages that do not ship with types, you can specify their types with a @deno-types directive. For example, using a @types package, you would import it like so:
import express from "npm:express@^4.17";
import express from "npm:express@^4.17";
4. If you need to include Node types that might be referenced in an npm package's types, you must add a types reference directive to the
Deno AI Helper
Deno AI Helper•5mo ago
@types/node package. Remember that these packages are subject to the same permissions as other code in Deno, and no npm install or node_modules folder is necessary when using npm: specifiers in Deno. If you've tried these steps and are still having issues, could you provide more details about the specific package and the errors you're encountering? This information will help in giving more targeted advice. 🦕
Necmttn | Craftgen.ai
Necmttn | Craftgen.aiOP•5mo ago
The issue is due to peerdependecys not being installed or correlated to the package
Necmttn | Craftgen.ai
Necmttn | Craftgen.aiOP•5mo ago
GitHub
GitHub - Necmttn/deno-peer-deps
Contribute to Necmttn/deno-peer-deps development by creating an account on GitHub.
Necmttn | Craftgen.ai
Necmttn | Craftgen.aiOP•5mo ago
created a repo of test
Necmttn | Craftgen.ai
Necmttn | Craftgen.aiOP•5mo ago
No description