Repository: deno
Issue: `deno install -g` doesn't use base of original imports
Labels: install

Version: Deno 2.1.4
Using Windows 11

I've posted a question on stackoverflow, at https://stackoverflow.com/questions/79317608/deno-2-configuration-file-not-detected-when-using-compile-command  that may explain further

But, here's the jist. If I run `deno install -fgA src/bin/compile.js` with the current directory set to my project directory (~/vllu below), the files added to my ~/.deno/bin folder include the --no-config option, even though my project root contains a deno.jsonc file. FYI, my directory structure is:

```
~
   vllu
      deno.jsonc
      src
         lib
            llutils.js
         bin
            compile.js

```
And I ALWAYS leave the current directory at my project root (i.e. ~/vllu)

The docs I see when running `deno compile --help` clearly state that the config file should be automatically detected and used. But that's not all. Since there is a --config option for specifying the config file to use, I tried using 

`deno install -fgA --config ./deno.jsonc src/bin/compile.js`

which resulted in this odd behavior: 

1) my config file was copied to the ~/.deno/bin directory, which is odd because the script being installed is NOT copied, but used directly, i.e. if I make changes to compile.js, the command would use those changes, but if I make changes to my deno.jsonc file, those wouldn't be used because the file is copied.

2) the copied file has the file extension .json even though my config file is named deno.jsonc. It is, in fact, not a valid JSON file since it contains comments and trailing commas. Attempts to load the file as a true JSON file is bound to fail.

Then, after executing the above install command, I found files `compile `and `compile.cmd` in my `~/.deno/bin` folder:

```
#!/bin/sh
# generated by deno install
deno "run" "--allow-all" "--config" "C:\Users\johnd\.deno\bin\.compile.deno.json" "file:///C:/Users/johnd/vllu/src/bin/compile.js" "$@"

```
```
% generated by deno install %
@deno "run" "--allow-all" "--config" "C:\Users\johnd\.deno\bin\.compile.deno.json" "file:///C:/Users/johnd/vllu/src/bin/compile.js" %*

```
I'm not sure why I need both, but anyway... when I try to run the command `compile llutils` (my compile script automatically finds the location of the src/lib/llutils.js file), I get the error:

$ compile llutils
error: Module not found "file:///C:/Users/johnd/.deno/bin/src/lib/llutils.js".
    at file:///C:/Users/johnd/vllu/src/bin/compile.js:7:9

The file path it's looking for is entirely wrong. It seems to be looking for src/lib/llutils.js in my ~/.deno/bin folder. FYI, the compile.js script is importing from` '@jdeighan/vllu/llutils.js'` and the config file contains:

`"@jdeighan/vllu/": "./src/lib/",
`
in the imports section. I'm guessing that Deno changes the current directory, which would, I think, cause the bad file path. If Deno is going to change the working directory, it should modify the relative paths used in the config file. 

Also, I tried changing the copied config file extension to` .jsonc`, and also changing that file extension in both the files `compile `and `compile.cmd`, but that made no difference. Perhaps deno loads it as a `.jsonc` file, even if the extension is `.json`, which I find very confusing.