Comments (62)
1- Install this extension : here.
2- Ctrl+Shift+P in your working directory.
3- Write this: Deno: Initialize Workspace Configuration.
4- Yes.
5- Yes.
Your welcome.
from vscode_deno.
@rshashik
are you sure your settings.json
is valid?
for me it works, same versions as you + .vscode/settings.json
:
{ "deno.enable": true }
after - restart IDE and it works (for me)
from vscode_deno.
from vscode_deno.
I had this issue, which was caused by this line in my VS Code settings.json
:
"typescript.tsserver.experimental.enableProjectDiagnostics": true
I diagnosed this by starting VS Code with a blank profile (code --user-data-dir=/tmp/vscode .
) and seeing that Deno support worked, so I removed lines from my VS Code config until I found the culprit.
This also fixed the error An import path cannot end with a '.ts' extension.
.
from vscode_deno.
I had this issue, which was caused by this line in my VS Code
settings.json
:
"typescript.tsserver.experimental.enableProjectDiagnostics": true
I diagnosed this by starting VS Code with a blank profile (
code --user-data-dir=/tmp/vscode .
) and seeing that Deno support worked, so I removed lines from my VS Code config until I found the culprit.This also fixed the error
An import path cannot end with a '.ts' extension.
.
For some reason, removing wasn't enough, even it wasn't enabled in User settings. But explicitly disabling it in .vscode/settings.json
worked. Maybe we could mention this somewhere in the extension README?
{
"deno.enable": true,
"deno.lint": true,
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"typescript.tsserver.experimental.enableProjectDiagnostics": false
}
sorry for the noise.
from vscode_deno.
If you still have errors like Cannot find name 'Deno'. ts(2304)
, try the following:
View > Command Palette... > deno: Init > Enable deno lint? Yes
Deno is now set up. You can enable and disable settings (like
--unstable
) in the.vscode/settings.json
file. Before the extension will work you need to reload VS Code.
Click on Reload window
vscode/settings.json
will contain:
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true
}
If you still have errors like Could not find module "https://deno.land/..." locally. Deno Language Server(1005)
, try the following:
View > Command Palette... > deno: Restart Deno Language Server
from vscode_deno.
@itajaja , That's the problem, the "new" one is old (1.24.0), and the deprecated is newer (1.34.0). In other words, the extension from denoland doesn't work yet, but the extension from justjavac does, but you'll get a annoying deprecation popup on startup.
from vscode_deno.
why is it so hard to get deno setup going yikes
from vscode_deno.
If you are using a custom tsconfig.json
with Deno and getting this message, the solution is to add "deno.ns"
to lib
:
"compilerOptions": {
"lib": [
"esnext",
"dom",
"deno.ns"
]
from vscode_deno.
i had the same issue what worked for me was to press Ctrl+Shit+p in VS Code then Type Deno in the search. And click Deno Initialize workspace
from vscode_deno.
I think a number of people misunderstood this comment. It turns out the deprecated deno plugin by justjavac actually has a newer release than the official plugin (this one) - it worked for me.
from vscode_deno.
I did Ctrl+Shift+P -> Initialize Workspace Configuration, which created me .vscode/settings.json
:
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": false
}
But still the problem occurs:
vscode-deno: v3.7.0
deno 1.11.5 (release, x86_64-pc-windows-msvc)
v8 9.1.269.35
typescript 4.3.2
UPD. I created a new issue here: #466
from vscode_deno.
I had this issue, which was caused by this line in my VS Code
settings.json
:
"typescript.tsserver.experimental.enableProjectDiagnostics": true
I diagnosed this by starting VS Code with a blank profile (code --user-data-dir=/tmp/vscode .
) and seeing that Deno support worked, so I removed lines from my VS Code config until I found the culprit.
This also fixed the errorAn import path cannot end with a '.ts' extension.
.For some reason, removing wasn't enough, even it wasn't enabled in User settings. But explicitly disabling it in
.vscode/settings.json
worked. Maybe we could mention this somewhere in the extension README?{ "deno.enable": true, "deno.lint": true, "editor.formatOnSave": true, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "typescript.tsserver.experimental.enableProjectDiagnostics": false }sorry for the noise.
Not noise! This worked for me, worth a try for others. Wow, weird bug.
from vscode_deno.
you can upgrade
no, I am already using the latest version of the right plugin, not the deprecated one
from vscode_deno.
Maybe this answer is helpful, configuring Deno types in VS Code.
Currently, this is a working solution for me with the built-in TypeScript version of VS Code 1.45.1
. If you need to configure a custom workspace version, there are some more steps to do - take a look at the docs here.
from vscode_deno.
@rshashik restart your ide - what have you tried so far?
- installed deno 1.4.6
- installed denon v2.4.4
- installed denoland.vscode-deno extension in my mac
- created .vscode/settings.json file and set "deno.enable": true
- created server.ts file
`import { Application } from "https://deno.land/x/oak/mod.ts";
import router from "./routes.ts";
const port = Deno.env.get("PORT") || 5000;
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
console.log(Server running on port ${port}
);
await app.listen({ port: +port });`
Error in my vscode editor at Deno.env.get("PORT"): Cannot find name 'Deno'.ts(2304)
https://github.com/rshashik/pdr.git
from vscode_deno.
Deno output:
Found deno, version:
deno: 1.0.2
v8: 8.4.300
typescript: 3.9.2
from vscode_deno.
If you are using a custom
tsconfig.json
with Deno and getting this message, the solution is to add"deno.ns"
tolib
:"compilerOptions": { "lib": [ "esnext", "dom", "deno.ns" ]
I was having the same issue, and this is what actually finally solved it for me. Thank you!
from vscode_deno.
I had the same issue and it looks like when I install the extension from vs marketplace the typescript-deno-plugin
version running is v1.29.0 π
I've pulled the repo and build it locally then I've installed the .vsix manually and now it's working and it's running typescript-deno-plugin v1.31.0
. Not ideal but it's working (at least for me π)
from vscode_deno.
Note that you may have to reinstall the extension to get this fix (I did, even though I newly installed it).
from vscode_deno.
I encountered this issue as well today.
For me the following two steps fixed it:
- press Ctrl+Shift+p and choose 'Deno: Initialize Workspace' to initialize the workspace.
- press Ctrl+Shift+p and choose 'Deno: Restart Language Server'.
Also running step 2 was the missing step for me.
Thanks but this doesn't help in my case π It seems there are various reasons why this might happen. In my case it's likely has something to do with OS Windows, but can't say for sure. For those who tried all the hints from here and nothing works, I recommend to proceed / add your details in this new issue, to help investigate the problem: #466
from vscode_deno.
If you are using a custom
tsconfig.json
with Deno and getting this message, the solution is to add"deno.ns"
tolib
:"compilerOptions": { "lib": [ "esnext", "dom", "deno.ns" ]
You are the true MVP. Everyone else be going in circles.
"Do X. X didn't work. Do X. X didn't work. repeat"
from vscode_deno.
In case it helps anyone else: I had this issue because I disabled the built-in TypeScript and JavaScript Language Features plugin in vscode to use the volar plugin's takeover mode for VueJS development.
Searching @builtin TypeScript
and then enabling the TypeScript and JavaScript Language Features
plugin solved the issue for me.
from vscode_deno.
I encounter this issue on the latest VSCode 1.45.1 on Mac. And I just figured out and resolve the problem by upgrade the global tsc to latest 3.9.3 and config VSCode to use that version with "typescript.tsdk".
I guess that was due to the VSCode inline tsc 3.8.3 didn't work well with deno's plugin, while deno's inline one is 3.9.2.
Checkout this link https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions for the steps.
from vscode_deno.
I'm using latest VSCode Insider which also uses latest Typescript 3.9.4, and the denoland version of the extension doesn't work anyway (No import and no Deno namespace, but deno in the status bar). Both deprecated versions of the extension works (justjavac and axetroy).
from vscode_deno.
Closed by #77
from vscode_deno.
If you still have errors like
Cannot find name 'Deno'. ts(2304)
, try the following:
View > Command Palette... > deno: Init > Enable deno lint? Yes
Deno is now set up. You can enable and disable settings (like
--unstable
) in the.vscode/settings.json
file. Before the extension will work you need to reload VS Code.Click on
Reload window
vscode/settings.json
will contain:{ "deno.enable": true, "deno.lint": true, "deno.unstable": true }
If you still have errors like
Could not find module "https://deno.land/..." locally. Deno Language Server(1005)
, try the following:
View > Command Palette... > deno: Restart Deno Language Server
It works for me fine. Thank you!
from vscode_deno.
I solved this issue by installing and enabling the Deno plugin on VS Code
deno 1.30.2 (release, aarch64-apple-darwin)
v8 10.9.194.5
typescript 4.9.4
from vscode_deno.
Please open a separate issue about this problem. It requires more investigation. Make sure you are using latest Deno and VSCode extension.
from vscode_deno.
Some other situations can also lead to this issue, for example, if you are using the Volar extension. This can cause a conflict with the Deno extension, as Volar, to my knowledge, involves managing TypeScript. The management of TypeScript by both can lead to conflicts, and disabling the Volar extension should resolve the issue.
from vscode_deno.
I got the same issue. And i've tried all the recommended solutions.
The weird thing is that it was finding the Deno, and then "randomly" mid coding today it stopped. π€·ββοΈ
It still runs successfully but VScode is telling me it cant find it and the red lines are driving me crazy lol
But putting
/// <reference lib="deno.ns" />
at the top of my file (index.ts) worked.
Some other github issue talks about how certain libraries have a /// <reference no-default-lib="true"/>
which then throws everything amuck
from vscode_deno.
@joshpachner Thank you for pointing out that a TypeScript file seemingly anywhere in your project can cause this. In my case, I think it was an NPM package in Deno's cache, which I keep checked into my repository.
from vscode_deno.
from vscode_deno.
Yes, this happens to me too, the denoland plugin doesn't work at all while the deprecated justjavac does.
from vscode_deno.
I am seeing this issue too. I tried all the above solutions to no avail. I don't imagine this is intended behavior.
from vscode_deno.
I think a number of people misunderstood this comment. It turns out the deprecated deno plugin by justjavac actually has a newer release than the official plugin (this one) - it worked for me.
Not sure I would say that the comment was misunderstood. Seems pretty clear and it should probably be changed? Regardless, this solution worked for me as well
from vscode_deno.
nope, I have the new one, still deno doesn't work:
from vscode_deno.
I see, thanks for the clarification. well, since this is still the repo for the "new" one, the new one still has this bug that needs to be solved
from vscode_deno.
@itajaja , That's the problem, the "new" one is old (1.24.0), and the deprecated is newer (1.34.0). In other words, the extension from denoland doesn't work yet, but the extension from justjavac does, but you'll get a annoying deprecation popup on startup.
So is there an expected timeline for the official plugin to issue an update?
from vscode_deno.
reverting to the deprecated plugin until this issue is resolved
from vscode_deno.
Im facing the same issue. i installed latest Deno 1.4.6 version and denoland.vscode-deno extension. What is solution to this error??
from vscode_deno.
@rshashik restart your ide - what have you tried so far?
from vscode_deno.
@rshashik did you restart your IDE? Can you check the extension is enabled? Can you check itβs the correct link (click the link in the readme)?
from vscode_deno.
I'm also encountering this issue.
I can see that the deno extension is doing something, since as soon as I set it to "deno.enable": false
in my settings.json I get the An import path cannot end with a '.ts' extension. Consider importing [...] .ts(2691)
But when I set "deno.enable": true
those import errors disappear but I still have Cannot find name 'Deno'
. Types seems to default to any
everywhere, and development is a pain.
The very odd thing is that, sometime, and I've not been able to figure exactly how, through a combination of activating / deactivating the extension, changing code in my project, restarting the TS server, restarting the deno language server, it starts to work properlyβ¦
But whenever I leave vscode and come back to the project, its broken again :(
I've tried disabling most of my vscode extensions without success⦠The issue is there for me, and I think it's a nasty one to figure out if some people never experience it :/
from vscode_deno.
Same issue as in the OP, plus it doesn't pick up on cached modules.
deno info some_file.ts
correctly reports cached dependencies and their respective dependency trees. The scripts also run/bundle/install just as expected.
Deno.something(...)
reports Cannot find name 'Deno'.ts(2304)
and
import { some_module } from 'some_url';
reports Could not find module "some_url" locally.Deno Language Server(1005)
Environment (An ubuntu vm basically set up from scratch just to test deno out):
-Fresh ubuntu 20.04.1 installation.
-Fresh VSCode 1.15.1
-Fresh deno installation 1.4.6
-Deno extension 2.3.3
.vscode/settings.json:
{
"deno.enable": true,
"deno.unstable": false,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
}
The extension is enabled in VSCode. The deprecated version (justjavac.vscode-deno) does not show the behavior for Deno.something
but fails to pick up on the cached modules too.
from vscode_deno.
Thanks for the answer. Following the instructions, the second half worked great and vscode now correctly reports the modules as known. Unfortunately it is still unaware of the Deno
namespace and reports the familiar error. I recorded the steps, just in case, and you can look at the behavior here: https://streamable.com/cz2fkl
Another thing of note is that in tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"rootDirs": [
"./src",
"./tests"
]
}
}
vscode reports
File '$HOME/.cache/deno/lib.deno.unstable.d.ts' not found.ts
which probably is a more suitable hint at the cause here.
from vscode_deno.
@nitowa: are you sure Deno
is correctly installed ?
$ deno info
DENO_DIR location: "$HOME/.deno"
Remote modules cache: "$HOME/.deno/deps"
TypeScript compiler cache: "$HOME/.deno/gen"
lib.deno.unstable.d.ts
should be found in $HOME/.deno
, not in $HOME/.cache/deno
.
Deno <version>
should be showed at lower right of VSCode status bar eg TypeScript 4.1.2 Deno 1.5.4
.
Check your $DENO_DIR
envvar which should be set to $HOME/.deno
BTW, in your video, there is an Unexpected end of JSON input
error, probably in tsconfig.json
.
HTH,
Pierre
from vscode_deno.
The project I'm testing with is pretty much https://github.com/lampewebdev/deno-boilerplate unmodified. Not sure where the unexpected end of JSON came from, but tsconfig.json just reports the error from the previous post (and fwiw is valid json).
deno info
yields
DENO_DIR location: "$HOME/snap/deno/15/.cache/deno"
Remote modules cache: "$HOME/snap/deno/15/.cache/deno/deps"
TypeScript compiler cache: "$HOME/snap/deno/15/.cache/deno/gen"
which deno
/snap/bin/deno
deno -V
deno 1.4.6
$DENO_DIR
was in fact not set at all, but even after manually setting it, the error persists. Deno was installed via snap
from vscode_deno.
Deno
(without version) in status bar indicates that deno executable cannot be found in path.
Otherwise, Deno <version>
is displayed in status bar.
DENO-DIR
is used to locate both lib.deno.d.ts
and lib.deno.unstable.d.ts
files.
At start, those files will be created automatically.
If Cannot find name 'Deno'. ts(2304)
error persists, restart VSCode window.
from vscode_deno.
i had the same issue what worked for me was to press Ctrl+Shit+p in VS Code then Type Deno in the search. And click Deno Initialize workspace
This worked for me, after 2 hours of searching for a solution. Deno needs to get their extension in order... π
from vscode_deno.
i had the same issue what worked for me was to press Ctrl+Shit+p in VS Code then Type Deno in the search. And click Deno Initialize workspace
This worked for me, after 2 hours of searching for a solution. Deno needs to get their extension in order... π
The welcome page and instructions make it clear the this needs to be done, as very few people have every TypeScript project be a Deno one. Is there some way we could make these instructions clearer in order to "sort our extension out"?
from vscode_deno.
I encountered this issue as well today.
For me the following two steps fixed it:
- press Ctrl+Shift+p and choose 'Deno: Initialize Workspace' to initialize the workspace.
- press Ctrl+Shift+p and choose 'Deno: Restart Language Server'.
Also running step 2 was the missing step for me.
from vscode_deno.
Seeing a lot of people get tripped up on the deno.ns
I opened denoland/deno#15222 which would at least try to provide better information on how to resolve the issue.
from vscode_deno.
Had the same issue, resolved it by enabling Deno Language Server.
Open settings (β + . / Ctrl + .) and search for Deno:enable and active it either for the workspace or user profile.
from vscode_deno.
Does it really work?
.vscode/settings.json
{
"deno.enable": true,
"deno.lint": true,
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
from vscode_deno.
Does it really work?
.vscode/settings.json
{ "deno.enable": true, "deno.lint": true, "editor.formatOnSave": true, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" } }
Do you have an import map that maps constructs
to a fully qualified URL?
from vscode_deno.
Do you have an import map that maps
constructs
to a fully qualified URL?
Oh sorry forgot to include deno config file.
deno.jsonc
{
"imports": {
"cdk8s": "npm:[email protected]",
"constructs": "npm:[email protected]"
},
"tasks": {
"dev": "deno run --watch main.ts",
"build": "deno run --allow-env --allow-write main.ts"
},
"fmt": {
"options": {
"indentWidth": 4,
"lineWidth": 100,
"singleQuote": true
}
}
}
deno task build
command works and cdk8s yaml file works fine, it's just VSCode complaining :(
Edit: Actually I have another problem. With this import
import { KubeNamespace } from './imports/k8s.ts';
I'm getting the error.
An import path cannot end with a '.ts' extension. Consider importing './imports/k8s' instead.ts(2691)
from vscode_deno.
I got the same problem though none of the above worked unfortunately.
from vscode_deno.
I got the same problem though none of the above worked unfortunately.
same
from vscode_deno.
I got the same issue. And i've tried all the recommended solutions. The weird thing is that it was finding the Deno, and then "randomly" mid coding today it stopped. π€·ββοΈ It still runs successfully but VScode is telling me it cant find it and the red lines are driving me crazy lol
But putting
/// <reference lib="deno.ns" />
at the top of my file (index.ts) worked. Some other github issue talks about how certain libraries have a/// <reference no-default-lib="true"/>
which then throws everything amuck
I was having this issue and your suggestion solved it, but I was also getting cannot find name 'console'
when doing console.log
, which is still there.
from vscode_deno.
The civet extension for civet produces errors such as typescript(2307)
as opposed to ts(2307)
that can be difficult to track down in the context of resolving issues like those from the OP and others mentioned in this thread.
from vscode_deno.
I had this issue, which was caused by this line in my VS Code
settings.json
:
"typescript.tsserver.experimental.enableProjectDiagnostics": true
I diagnosed this by starting VS Code with a blank profile (code --user-data-dir=/tmp/vscode .
) and seeing that Deno support worked, so I removed lines from my VS Code config until I found the culprit.
This also fixed the errorAn import path cannot end with a '.ts' extension.
.For some reason, removing wasn't enough, even it wasn't enabled in User settings. But explicitly disabling it in
.vscode/settings.json
worked. Maybe we could mention this somewhere in the extension README?{ "deno.enable": true, "deno.lint": true, "editor.formatOnSave": true, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "typescript.tsserver.experimental.enableProjectDiagnostics": false }sorry for the noise.
Not noise! This worked for me, worth a try for others. Wow, weird bug.
This worked for me!
from vscode_deno.
Related Issues (20)
- Settings.json (typescript service not disabled) and Deno.json (excluded lint rules messages persist) HOT 14
- auto-import for `std` modules HOT 4
- LSP loses deno namespace info when switching from node subdirectory to deno subdirectory
- Ability to add package to deno.json via command palette?
- When using custom deno.json in workspace settings, fmt settings don't work and imports cause errors HOT 2
- Nothing works :( HOT 6
- Inconsistent deno fmt result between 1.41.3 and 1.42.0 HOT 4
- relative path import suggestions does not exclude `DENO_DIR`
- Jupyter notebook requires enabling deno in settings.json to disable TS even when deno.json exists
- Deno extension doesn't work in workspaces properly HOT 1
- Everything in Intellisense is duplicated HOT 2
- deno.importMap setting is ignored if deno.json includes an import map HOT 3
- readonly not considered to be initialized first HOT 1
- CWD for tests should be switched in case of partial deno workspace HOT 1
- Code lens does not work HOT 1
- Global types (reference types) not being applied HOT 2
- URL.parse() not available in v3.37.1 using Deno v1.43.4
- Import maps not recognized for nested deno projects HOT 1
- Failed to start inspector server at "127.0.0.1:9229"
- Deno cannot be selected as default formatter in Vscode after updating extension to 3.37.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode_deno.