Vscode_deno: Extension is not working

Created on 14 Aug 2020  ·  19Comments  ·  Source: denoland/vscode_deno

Describe the bug
hey i've installed latest deno version 1.3.0 , and have vscode insiders installed ,
before one week everything was working fine , yesterday i opened vscode , but the suggestions are not working
i have vscode insiders version 1.48.0 , and whenever i try to import some urls it gives red line errors

Expected behavior

extension should give suggestions,

Versions

vscode: 1.48.0
deno: 1.3.0
extension: 2.0.4

Most helpful comment

The extension was working for me fine yesterday with just "deno.enable": true. Today it's not working at all. There is no difference if it's installed or not. The only thing that changed was windows update but I doubt that has anything to do with it.

Btw, installing dependencies using npm is not a solution because Deno projects should not require anything Node related to work.

All 19 comments

Make sure that you have enabled the extension in .vscode/settings.json with deno.enable = true

Make sure that you have enabled the extension in .vscode/settings.json with deno.enable = true

Yes I've applied that settings , but doesn't seems to work

Did you try this "deno.enable": true because my URL errors were resolved after writing this in settings.json.

I have exactly the same problem. It worked with code-insiders yesterday, it doesn't work today with the the latest code-insiders nor with the just release vscode 1.48.

I have set deno.enable=true in .vscode/settings.json.

The only Deno command left is "deno: Restart Deno Language Server".

I am using Ubuntu 20.04, latest updates.

Edit: Noticed that both VSCode and the extension and the Typescript plugin changed. So not sure which it was. It did still work yesterday with Deno 1.3.0 so that should not be the problem.

The same on Windows 10 with lastest stable vscode, deno 1.3.0 and extension 2.0.10.

same issue:

macOS
deno 1.3.0
vscode_deno 2.0.10

// .vscode/settings.json
{
  "deno.enable": true
}

VS Code: 1.48.0

@ry @bartlomieju So I am having the same issue, and it seems to be related to typescript-deno-plugin not being loaded because it can not be found. I got this https://gist.github.com/lucacasonato/161064ddc428661faf6abb767b18a44a from my tsserver.log. It seems that somehow the typescript-deno-plugin isn't being built, (or included in the vsix package). This would also explain the weird behaviour a few versions back where the vscode plugin was the 2.x, but the typescript-deno-plugin seemed to still be running at the 1.x version.

@2nini @lem0nify @newtack @WhoAdarshPandya Could you all upload the contents of your tsserver.log (access by pressing Ctrl-Shift-P in VSCode, then > Typescript: Open TS Server log) to Gist and paste the link here?

经过 @lucacasonato 的提醒, 我找到了 typescript-deno-plugin 文档中的一句话:

If you are using a workspace version of TypeScript, you must manually install the plugin alongside the version of TypeScript in your workspace.

然后我手动安装了依赖, 解决了该问题:

npm install --save-dev typescript-deno-plugin typescript

并且使用了如下 vscode 设置:

// .vscode/settings.json
{
  "typescript.tsdk": "node_modules/typescript/lib",
  "deno.enable": true
}

After @lucacasonato's reminder, I found a sentence in the typescript-deno-plugin document:

If you are using a workspace version of TypeScript, you must manually install the plugin alongside the version of TypeScript in your workspace.

Then I installed the dependencies manually and solved the problem:

npm install --save-dev typescript-deno-plugin typescript

That shouldn't be needed though (it should ship alongside the plugin), and also that typescript-deno-plugin is the 1.x plugin, not the new 2.x plugin. A very temporary fix I guess.

虽然我在 deno 项目中使用了 npm, 但我认为目前并没有什么太大问题.

node + npm 目前有广泛的使用场景, 但 deno 能提供良好的浏览器代码兼容. 我在 package.json 文件中有许多开发依赖以帮助我.

截屏2020-08-15 16 34 58


Although I used npm in the deno project, I don't think there is a big problem at the moment.

Node + npm currently has a wide range of usage scenarios, but deno can provide good browser code compatibility. I have many development dependencies in the package.json file to help me.

The extension was working for me fine yesterday with just "deno.enable": true. Today it's not working at all. There is no difference if it's installed or not. The only thing that changed was windows update but I doubt that has anything to do with it.

Btw, installing dependencies using npm is not a solution because Deno projects should not require anything Node related to work.

@lucacasonato Same Error here.
I also get the "Failed to load module 'typescript-deno-plugin' from" Error.

Environment:
Ubuntu 18
VSCode v1.48.0
I tried it with Deno version 1.2.3 and 1.3.0
denoland.vscode-deno Version 2.0.10

TS Server Log:
https://gist.github.com/LinoBert/f9ab32616b6a7510c73e8a228b3c41bb

@axetroy
I tested switching back to Version 2.0.5 and 2.0.0 but for me that didn't work out.
When downgrading the extension major Version to 1.26.0 everything works fine with the current configuration(Deno 1.3.0 and VSCode v1.48.0).

Sorry for the breakage. 2.0.11 should be released momentarily with the fix.

Currently on 2.0.13. This does not appear to have been fixed, or at least not in the way that I had hoped 😅
I am currently missing autocomplete for any type of external dependency that imports/re-exports from local dependencies (any dependency from std for example).

// deps.ts
export * as path from "https://deno.land/[email protected]/path/mod.ts";
// mod.ts
import { path } from "./deps.ts";
path.resolve("xyz");

gives the following result:
image

Also on 2.0.13 and it is still not resolved (original error gone, now TS language server crashed 5 times).

Here is an excerpt from the log:

(just before file watchers):
Info 23 [11:51:51.508] DirectoryWatcher:: Added:: WatchInfo: /home/ralf/dev/play/scripts 1 undefined Project: /home/ralf/dev/play/scripts/tsconfig.json WatchType: Wild card directory
Info 24 [11:51:51.509] Elapsed:: 1ms DirectoryWatcher:: Added:: WatchInfo: /home/ralf/dev/play/scripts 1 undefined Project: /home/ralf/dev/play/scripts/tsconfig.json WatchType: Wild card directory
Info 25 [11:51:51.509] Loading global plugin typescript-vscode-sh-plugin
Info 26 [11:51:51.509] Enabling plugin typescript-vscode-sh-plugin from candidate paths: /usr/share/code-insiders/resources/app/extensions/typescript-language-features,/home/ralf/.vscode-insiders/extensions/denoland.vscode-deno-2.0.13,/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../..
Info 27 [11:51:51.510] Loading typescript-vscode-sh-plugin from /usr/share/code-insiders/resources/app/extensions/typescript-language-features (resolved to /usr/share/code-insiders/resources/app/extensions/typescript-language-features/node_modules)
Info 28 [11:51:51.512] typescript-vscode-sh-plugin initialized. Intercepting getEncodedSemanticClassifications and getEncodedSyntacticClassifications.
Info 29 [11:51:51.512] Plugin validation succeded
Info 30 [11:51:51.512] Loading global plugin typescript-deno-plugin
Info 31 [11:51:51.512] Enabling plugin typescript-deno-plugin from candidate paths: /usr/share/code-insiders/resources/app/extensions/typescript-language-features,/home/ralf/.vscode-insiders/extensions/denoland.vscode-deno-2.0.13,/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../..
Info 32 [11:51:51.512] Loading typescript-deno-plugin from /usr/share/code-insiders/resources/app/extensions/typescript-language-features (resolved to /usr/share/code-insiders/resources/app/extensions/typescript-language-features/node_modules)
Info 33 [11:51:51.536] Loading typescript-deno-plugin from /home/ralf/.vscode-insiders/extensions/denoland.vscode-deno-2.0.13 (resolved to /home/ralf/.vscode-insiders/extensions/denoland.vscode-deno-2.0.13/node_modules)
Info 34 [11:51:51.551] [typescript-deno-plugin] "Create typescript-deno-plugin"
Info 35 [11:51:51.552] Plugin validation succeded

(near the end)

Err 8240 [11:51:59.199] Exception on executing command {"seq":2,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"/home/ralf/dev/play/scripts/gen-deps.ts","fileContent":"//todo: using deps.json as input, generate all other relevant files (import map, package.json, etc.)\n//from it\n\nimport { run, runWithStringOutput } from \"./platform/shared/utils.ts\";\n\n//1. get unique list of dependencies with version and without\n\ninterface Dependencies {\n [s: string]: Dependency;\n}\n\ninterface Dependency {\n version: string;\n dependencies?: Dependencies;\n}\n\nconst packageWithVersions = new Map>();\nconst childVersions = new Set();\n\nfunction getNameAndVersion(name: string, version: string) {\n return ${name}.v${version};\n}\n\nfunction read_dep(\n ancestors: string[],\n name: string,\n dep: Dependency,\n level: number,\n) {\n const depName = getNameAndVersion(name, dep.version);\n packageWithVersions.set(depName, []);\n for (const ancestor of ancestors) {\n \n packageWithVersions.get(ancestor)!.push(depName);\n }\n if (!packages.has(name)) {\n const versions = new Set();\n versions.add(dep.version);\n packages.set(name, versions);\n } else {\n const versions = packages.get(name)!;\n if (!versions.has(dep.version)) {\n versions.add(dep.version);\n }\n }\n if (dep.dependencies === undefined) {\n return;\n }\n const newAncestors = [...ancestors, depName];\n read_deps(newAncestors, dep.dependencies, level + 1);\n}\n\nfunction getPackageName(fullName: string) {\n const index = fullName.indexOf(\".v\");\n return fullName.substr(0, index);\n}\n\nfunction read_deps(\n ancestors: string[],\n dependencies: Dependencies,\n level: number,\n) {\n for (const [key, value] of Object.entries(dependencies)) {\n const depName = getNameAndVersion(key, value.version);\n read_dep(ancestors, key, value, level);\n }\n}\n\nasync function getPackageVersion(\n node_modules_dir: string,\n packageName: string,\n) {\n const filePath = ${node_modules_dir}/${packageName}/package.json;\n const contents = await Deno.readTextFile(filePath);\n const json = JSON.parse(contents) as { version: string };\n return json.version;\n}\n\nasync function generateEsm(nodeModulesDir: string, vendorDir: string) {\n const json = await runWithStringOutput({\n cwd: nodeModulesDir,\n cmd: [\"npm\", \"ls\", \"-json\"],\n });\n const deps = JSON.parse(json) as Dependency;\n\n read_deps([], deps.dependencies!, 0);\n\n for (const key of packages.keys()) {\n const values: Set = packages.get(key)!;\n if (values.size > 1) {\n const rootVersion = await getPackageVersion(nodeModulesDir, key);\n for (const value of values) {\n const fullName = ${key}.v${value};\n const isRoot = rootVersion === value;\n if (!isRoot) {\n childVersions.add(fullName);\n }\n }\n }\n }\n\n let maxCount = 0;\n let maxKey = \"\";\n console.log(\"all packages with version:\");\n for (const key of packageWithVersions.keys()) {\n const packageName = getPackageName(key);\n //console.log(key);\n const deps = packageWithVersions.get(key)!;\n if (maxCount < deps.length) {\n maxCount = deps.length;\n maxKey = key;\n }\n const excludeDeps = deps.filter((d) => !childVersions.has(d)).map((d) =>\n external:${getPackageName(d)}\n );\n const options = {\n cwd: nodeModulesDir,\n cmd: [\n \"esbuild\",\n \"--bundle\",\n ./${packageName}/index.js,\n --outdir=${vendorDir}/${packageName},\n \"--format=esm\",\n ...excludeDeps,\n ],\n };\n //console.log(options);\n try {\n await run(options);\n console.log(successfully generated package ${packageName});\n } catch (e) {\n //console.log(Error generating package ${packageName}: ${e});\n }\n\n //esbuild --bundle ./react/index.js --outdir=/home/ralf/dev/vendor/dev/react --format=esm --minify --external:object-assign\n }\n console.log(max dep count is: ${maxCount} for ${maxKey});\n}\n\n/\n#!/usr/bin/env -S deno run -A --unstable --importmap=import_map.json\nimport { getFileHash } from \"./platform/shared/fileUtils.ts\";\nconst hash = await getFileHash(\"./run.ts\");\n\n//esbuild for graphql: esbuild --bundle ./types/node_modules/graphql/index.js --sourcemap --outdir=./web --format=esm --minify\n//esbuild --bundle ./types/node_modules/react/index.js --sourcemap --outdir=./web --format=esm --minify\nesbuild --bundle ./types/node_modules/react/index.js --sourcemap --outdir=./web --format=esm --minify --define:process.env.NODE_ENV=\"production\"\n//\"graphql\": \"./types/node_modules/graphql/index.d.ts\",\nconsole.log(hash);\n\n/\n\nawait generateEsm(\n \"/home/ralf/dev/play/types/node_modules\",\n \"/home/ralf/dev/vendor/dev\",\n);\n\n//get for each package the complete list of dependencies (recursive)\n","projectRootPath":"/home/ralf/dev/play/scripts","scriptKindName":"TS"}]}}:

Debug Failure. False expression.

Error: Debug Failure. False expression.
    at watchFailedLookupLocationOfResolution (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:107121:22)
    at Array.forEach (<anonymous>)
    at watchFailedLookupLocationOfNonRelativeModuleResolutions (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:107156:29)
    at Map.forEach (<anonymous>)
    at clearPerDirectoryResolutions (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:106893:50)
    at Object.finishCachingPerDirectoryResolution (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:106898:13)
    at ConfiguredProject.Project.updateGraphWorker (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:148266:38)
    at ConfiguredProject.Project.updateGraph (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:148197:42)
    at ConfiguredProject.updateGraph (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:149131:63)
    at ProjectService.createLoadAndUpdateConfiguredProject (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:150835:25)
    at ProjectService.assignProjectToOpenedScriptInfo (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:151733:44)
    at /usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:152056:97
    at Object.flatMap (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:513:25)
    at ProjectService.applyChangesInOpenFiles (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:152056:41)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:153075:46)
    at /usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:154947:88
    at IOSession.Session.executeWithRequestId (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:154938:28)
    at IOSession.Session.executeCommand (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:154947:33)
    at IOSession.Session.onMessage (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:154971:35)
    at Interface.<anonymous> (/usr/share/code-insiders/resources/app/extensions/node_modules/typescript/lib/tsserver.js:157187:27)
    at Interface.emit (events.js:223:5)
    at Interface._onLine (readline.js:315:10)
    at Interface._normalWrite (readline.js:460:12)
    at Socket.ondata (readline.js:172:10)
    at Socket.emit (events.js:223:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)

~I can now confirm that switching back to v1 solves my type hint problems~

Edit: Seems like the real culprit in my case was a custom DENO_DIR value. Resetting and reinstalling completely solved my issue

Was this page helpful?
0 / 5 - 0 ratings