# pkg-file-resolver

> It's __dirname but for pkg'd windows applications

Latest version **1.0.15** (published 2022-06-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install pkg-file-resolver
pnpm add pkg-file-resolver
yarn add pkg-file-resolver
bun add pkg-file-resolver
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2022-06-14 |
| First published | 2022-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kobe Rankich kobe@joltindustries.fish |
| Maintainers | taj4k |
| Keywords | pkg, dirname, filesystem |

## Links

- npm: https://www.npmjs.com/package/pkg-file-resolver
- Repository: https://github.com/TAJ4K/pkg-file-resolver
- Issues: https://github.com/TAJ4K/pkg-file-resolver/issues
- npm.io page: https://npm.io/package/pkg-file-resolver

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.15 (latest) — 2022-06-14
- 1.0.14 — 2022-06-14
- 1.0.13 — 2022-06-14
- 1.0.12 — 2022-06-14
- 1.0.11 — 2022-06-14
- 1.0.10 — 2022-06-14
- 1.0.9 — 2022-06-14
- 1.0.8 — 2022-06-14
- 1.0.7 — 2022-01-30
- 1.0.6 — 2022-01-26
- 1.0.5 — 2022-01-26
- 1.0.4 — 2022-01-26
- 1.0.3 — 2022-01-26
- 1.0.2 — 2022-01-26
- 1.0.1 — 2022-01-26
- … 1 more at https://npm.io/package/pkg-file-resolver/versions

## README

# pkg-file-resolver
Easily fix the shortcomings of referencing files locally to your pkg'd executable

## Use
First install the pkg-file-resolver using the npm command line tool
```
npm i -g pkg-file-resolver
```
Then, to use it in your code require it as follows:
```js
const { __resolve } = require("pkg-file-resolver")

console.log(__resolve)
```

## Goal
Within the pkg system the files that are compiled are adding into a snapshot system where they run like they're in a separate drive. This complicates things when you try to reference files local to the exe, as the node program thinks it's in an entirely different drive.  
|                       | node               | pkg                   |
|-----------------------|--------------------|-----------------------|
| __filename            | /dir/file.js       | /snapshot/dir/file.js |
| __dirname             | /dir               | /snapshot/dir         |
| process.cwd()         | /dir as of the cmd | /Users/user           |
| process.execPath      | /node.exe          | /dir/file.exe         |
| process.argv[0]       | /node.exe          | /dir/file.exe         |
| process.argv[1]       | /dir/file.js       | /snapshot/dir/file.js |
| require.main.filename | /dir/file.js       | /snapshot/dir/file.js |
| __resolve             | /dir               | /dir                  |

pkg-file-resolver stands to help jump over this obstacle of just getting the local directory

---
_Source: https://npm.io/package/pkg-file-resolver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
