-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a hint on error about 'Relative import path ... not prefixe…
…d with ...' (#25430) Running a file like: ``` import "@std/dotenv/load"; ``` Without a mapping in `imports` field of `deno.json` or `dependencies` of `package.json` will now error out with a hint: ``` error: Relative import path "@std/dotenv/load" not prefixed with / or ./ or ../ hint: Try running `deno add @std/dotenv/load` at [WILDCARD]bare_specifier_without_import/main.ts:1:8 ``` Closes #24699 --------- Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
- Loading branch information
1 parent
105c2e3
commit acd01eb
Showing
10 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/specs/cache/with_bare_import/095_cache_with_bare_import.ts.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ | ||
hint: If you want to use a JSR or npm package, try running `deno add foo` | ||
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD] |
1 change: 1 addition & 0 deletions
1
tests/specs/check/with_bare_import/095_cache_with_bare_import.ts.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ | ||
hint: If you want to use a JSR or npm package, try running `deno add foo` | ||
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"args": "run main.ts", | ||
"output": "main.out", | ||
"exitCode": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
error: Relative import path "@std/dotenv/load" not prefixed with / or ./ or ../ | ||
hint: If you want to use a JSR or npm package, try running `deno add @std/dotenv/load` | ||
at [WILDCARD]bare_specifier_without_import/main.ts:1:8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import "@std/dotenv/load"; | ||
|
||
console.log(Deno.env.get("GREETING")); // hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[WILDCARD]error: Failed resolving types. Relative import path "baz" not prefixed with / or ./ or ../ | ||
hint: If you want to use a JSR or npm package, try running `deno add baz` | ||
at [WILDCARD]/type_definitions/bar.d.ts:[WILDCARD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
error: Relative import path "fs" not prefixed with / or ./ or ../ | ||
If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"). | ||
hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"). | ||
at file:///[WILDCARD]/main.ts:1:16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[WILDCARD]Config file found at '[WILDCARD]with_package_json[WILDCARD]with_stop[WILDCARD]some[WILDCARD]nested[WILDCARD]deno.json' | ||
[WILDCARD] | ||
error: Relative import path "chalk" not prefixed with / or ./ or ../ | ||
hint: If you want to use a JSR or npm package, try running `deno add chalk` | ||
at file:///[WILDCARD]with_package_json/with_stop/some/nested/dir/main.ts:3:19 |