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

Installed VSCode plugin but still not able to catch deno syntax #48

Closed
zemse opened this issue May 20, 2020 · 22 comments
Closed

Installed VSCode plugin but still not able to catch deno syntax #48

zemse opened this issue May 20, 2020 · 22 comments

Comments

@zemse
Copy link

zemse commented May 20, 2020

Following the tutorial in the docs:

const res = await fetch("https://jsonplaceholder.typicode.com/todos/1");
const body = new Uint8Array(await res.arrayBuffer());
await Deno.stdout.write(body);

I still get underline on the await:

'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.ts(1375)

And underline on the Deno

Cannot find name 'Deno'.ts(2304)

while if I run the file with deno, it obv runs. But vscode underlines are very irritating as well as it is not giving any type suggestions for Deno object.

I installed the plugin Deno 1.32.0 by justjavac. I tried doing [command]+[p] and > Enable Deno, which says deno is already enabled.

I tried to find any similar issue but seems it's not there while my issue is very basic regarding installation. I went through Readme but not able to solve the problem. Can you please help me what more I need to do to get it working?

@zemse
Copy link
Author

zemse commented May 21, 2020

Hey, I just uninstalled justjavac's 1.32.0 and installed axetroy's 3.7.0 and it's working wonderful as expected. What's the matter with justjavac version? It's got like 16k downloads while 6k on axetroy's. How come so many people don't get this error?

@justjavac
Copy link
Contributor

@zemse Can you provide a tsserver.log file, I will fix this bug

@zemse
Copy link
Author

zemse commented May 22, 2020

Hi, here is the file. tsserver.log.

@zemse
Copy link
Author

zemse commented May 22, 2020

I just called > Deno: Enable Deno on your plugin, and it created a .vscode dir containing

{
  "deno.enable": true
}

I did try this yesterday, enable and disable a number of times while .vscode dir wasn't being created.

But now it is being created, making the plugin's work. Looks like there isn't any issue from the plugin side and maybe this mac just went silly and needed a restart :( My bad, pardon for the trouble. Closing the issue.

@zemse zemse closed this as completed May 22, 2020
@zemse
Copy link
Author

zemse commented May 22, 2020

@justjavac I've run into same problem again, I have "deno.enable": true, in the settings.json file but still it appears like if the plugin is not active. I tried disabling Deno using > Deno: Disable Deno and re-enabling it again. Also observed that enabling and disabling flips deno.enable boolean value too. Can you please look into my tsserver.log file?

@zemse zemse reopened this May 22, 2020
@justjavac
Copy link
Contributor

Info 30   [23:42:6.187] Loading global plugin typescript-deno-plugin
Info 31   [23:42:6.187] Enabling plugin typescript-deno-plugin from candidate paths: /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features,/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../..
Info 32   [23:42:6.187] Loading typescript-deno-plugin from /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features (resolved to /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules)
Info 33   [23:42:6.198] Loading typescript-deno-plugin from /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js/../../.. (resolved to /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/node_modules)
Info 34   [23:42:6.203] Failed to load module 'typescript-deno-plugin' from /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules: Error: Could not resolve JS module 'typescript-deno-plugin' starting at '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules'. Looked in: /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/Resources/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/Contents/node_modules/typescript-deno-plugin/index.jsx, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin/package.json, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin.js, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin.jsx, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin/index.js, /Applications/Visual Studio Code.app/node_modules/typescript-deno-plugin/index.jsx, /Applications/node_modules/typescript-deno-plugin/package.json, /Applications/node_modules/typescript-deno-plugin.js, /Applications/node_modules/typescript-deno-plugin.jsx, /Applications/node_modules/typescript-deno-plugin/index.js, /Applications/node_modules/typescript-deno-plugin/index.jsx, /node_modules/typescript-deno-plugin/package.json, /node_modules/typescript-deno-plugin.js, /node_modules/typescript-deno-plugin.jsx, /node_modules/typescript-deno-plugin/index.js, /node_modules/typescript-deno-plugin/index.jsx
    at Object.resolveJSModule (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:29284:19)
    at Object.sys.require (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:147642:45)
    at Function.Project.resolveModule (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:139196:35)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:140205:36
    at Object.firstDefined (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:197:26)

This extension will first look for typescript-deno-plugin in typescript-language-features, then look for it in justjavac.vscode-deno.

Judging from the log, it didn't look in the justjavac.vscode-deno installation directory, and reported an error directly.

When you open the ts file, did you see the Deno extension information in the status bar?

@justjavac
Copy link
Contributor

If it is a problem with the plugin installation, you can press Cmd + Shift + P, enter "openexlog", you will see the log file exthost.log

@zemse
Copy link
Author

zemse commented May 25, 2020

I do see Deno 1.0.2. While I was getting this too. Once again I checked that deno.enable is true in .vscode/settings.json.
This is the file exthost.log.

Screenshot 2020-05-25 13 56 09

Few months ago in a different project, I did some setting in vscode to pick typescript version in ./node_modules/typescript in the vscode because a bug was fixed in latest typescript version and I wanted it instead of default typescript of vscode. Is it possible that this might be causing the problem? However, when I open a deno project, then I get a notification that vscode is using default typescript because it couldn't find the node_modules one.

@teroyks
Copy link

teroyks commented May 28, 2020

And underline on the Deno

Cannot find name 'Deno'.ts(2304)

I have this same issue in VS Code. I can see 'Deno 1.0.2' on the status bar, and other Deno syntax (such as import, await) seems to work (VS Code doesn't report problems on them, only on the Deno name so far).

@iMarv
Copy link

iMarv commented May 29, 2020

Getting the same issue with the "official" denoland.vscode-deno, but got it working with the deprecated justjavac.vscode-deno.

The denoland.Deno extension seems to be completely outdated compared to the justjavac.vscode-deno/
Do they share the same version numbers or is denoland.vscode-deno@1.24.0 === justjavac.vscode-deno@1.34.0?

e/

current denoland.vscode-deno works fine for me

@justjavac
Copy link
Contributor

@iMarv denoland.vscode-deno@1.24.0 !== justjavac.vscode-deno@1.34.0

justjavac.vscode-deno@1.34.0 is the master branch of denoland/vscode_deno

denisbrodbeck added a commit to denisbrodbeck/vscode_deno that referenced this issue Jun 6, 2020
Fix wrong VS Code Extension ID.
Explicitly `await` (and catch) `deno.generateDtsForDeno`, so all definition files are in place, before the extension finishes activation phase.

fixes denoland#74, denoland#66, denoland#62, denoland#48
ry pushed a commit that referenced this issue Jun 6, 2020
Fix wrong VS Code Extension ID.
Explicitly `await` (and catch) `deno.generateDtsForDeno`, so all definition files are in place, before the extension finishes activation phase.

fixes #74, #66, #62, #48
@ry
Copy link
Member

ry commented Jun 6, 2020

Closed by #77

@ry ry closed this as completed Jun 6, 2020
@jakubtomas108
Copy link

well, it still doesnt working

@petekp
Copy link

petekp commented Aug 30, 2020

I'm setting up Deno for the first time in a new project and the VSCode extension host log shows this error:

[2020-08-30 14:35:30.746] [exthost] [error] Activating extension denoland.vscode-deno failed due to an error:
[2020-08-30 14:35:30.753] [exthost] [error] Error: Cannot get typescript APIs. try restart Visual Studio Code.
    at getTypescriptAPI (/Users/petepetrash/.vscode/extensions/denoland.vscode-deno-2.0.16/client/out/client/src/extension.js:31:17)
    at Extension.activate (/Users/petepetrash/.vscode/extensions/denoland.vscode-deno-2.0.16/client/out/client/src/extension.js:268:28)
    at Function._callActivateOptional (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:877:509)
    at Function._callActivate (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:877:160)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:875:492
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Promise.all (index 2)

Restarting VSCode and re-installing the extension did not solve the issue. Using VSCode 1.48.2 and tsc@4.0.2.

Started a new issue for this error: #189

@TranXuanHoang
Copy link

I got the same phenomenal in which Deno code suggestion and autocompletion did not work after installing denoland's vscode_deno. After trying around I found the following steps help VS Code understands Deno - though this isn't a configuration recommended by the plugin's official documentation

  • Create a directory named .vscode and then create a settings.json file inside that directory. Put the following JSON config in that file

    your-project-workspace/.vscode/settings.json

    {
      "deno.enable": true,
    }
  • Open VS Code Settings File > Preferences > Settings (or Ctr + , on Windows / Cmd + , on macOS). Search deno, then select Extensions > Deno fron the search result filter.
    image

  • Check the Controls whether Deno is enabled or not to enable Deno like the above image capture.

  • Restart VS Code, and hopefully Deno suggestion and autocompletion will work
    image

@merima98
Copy link

merima98 commented Oct 16, 2020

Thank you @TranXuanHoang! It was so helpful to me.

@kevinXmichael
Copy link

Perhaps init deno will solve the problem: In vscode "show all commands" via CMD/CTRL + SHIFT + P and search for init deno, run it. Helped me to solve all problems with shown errors in vscode with deno.

@Timmmm
Copy link

Timmmm commented May 15, 2021

Hmm I still have this issue, and I have enabled the Deno extension for this workspace and restarted VSCode.

image

With Deno 1.10.1.

@Timmmm
Copy link

Timmmm commented May 15, 2021

Ah it seems like you have to do deno run <script.ts> in order for Deno to download the imports. That kind of sucks; other language extensions offer to do that for you (e.g. Dart).

Also the ts error is still there so it seems like the Deno extension isn't disabling Typescript support as it says it should here:

image

@Timmmm
Copy link

Timmmm commented May 15, 2021

Ah you can manually set this in your workspace settings:

"typescript.validate.enable": false,
"javascript.validate.enable": false,

Still it would be nice if the Deno extension did that for you as it claims to.

@filipe-freire
Copy link

Perhaps init deno will solve the problem: In vscode "show all commands" via CMD/CTRL + SHIFT + P and search for init deno, run it. Helped me to solve all problems with shown errors in vscode with deno.

Just tried the solution mentioned here, and it worked 💯. Thanks for sharing!

@Stokestack
Copy link

Stokestack commented Sep 2, 2022

I seemed to have the Deno extension working in VS Code. After I found that console.log() was sending nothing to the console, I searched online and created a launch.json file that included "outputCapture": "std".

After that, the Run/Debug pane on the left changed its appearance. It no longer has the two big buttons at the top to start debugging, but rather a "Launch program" drop-down at the top and some sections for variables, watch, call stack. Upon pressing "Launch program," I get:

error: Module not found "file:///Users/me/data/Mustache_test/main.ts".

But nothing calls for main.ts, which I've never had in this directory. I assume that this means the Deno integration isn't working (I'm brand-new to Deno and JS/TS development). I re-ran the "configure this workspace for Deno" option from the command palette, which claimed success. No change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests