From acd01eb2b41e37a480943f79cfa28fc220c4baca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 5 Sep 2024 07:25:56 +0100 Subject: feat: Add a hint on error about 'Relative import path ... not prefixed 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 https://github.com/denoland/deno/issues/24699 --------- Co-authored-by: David Sherret --- tests/testdata/run/with_package_json/with_stop/main.out | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/testdata/run/with_package_json') diff --git a/tests/testdata/run/with_package_json/with_stop/main.out b/tests/testdata/run/with_package_json/with_stop/main.out index f5eb79ca6..afab4910c 100644 --- a/tests/testdata/run/with_package_json/with_stop/main.out +++ b/tests/testdata/run/with_package_json/with_stop/main.out @@ -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 -- cgit v1.2.3