Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jlarky/determine-package-type
Determine Node Package Type
https://github.com/jlarky/determine-package-type
Last synced: about 1 month ago
JSON representation
Determine Node Package Type
- Host: GitHub
- URL: https://github.com/jlarky/determine-package-type
- Owner: JLarky
- Created: 2024-07-13T18:55:16.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-07-13T19:17:38.000Z (6 months ago)
- Last Synced: 2024-07-14T20:09:58.886Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Determine Node Package Type
Determine if node thinks this current folder should be considered module or commonjs.
Node has a bunch of rules to determine if a file with `.js` should be treated as `.cjs` or `.mjs`.
Usually, this is determined by `"type"` field in the `package.json` but if you don't have that set value from the parent (or the parent's parent and so on) will be used.To cut down on the guesswork this package will just create both commonjs version and module version of the file and see which one works.
### Usage
```bash
deno run -A jsr:@jlarky/determine-package-type
```will output either `module` or `commonjs`.
You can also pass a path to a folder you want to try to determine the package type for.
```bash
deno run -A jsr:@jlarky/determine-package-type ./some-folder
```Since this package is using Deno you can use it in the safe mode:
```bash
deno run jsr:@jlarky/determine-package-type
```then just hit "y" + Enter when asked to check what exact permissions are needed.
Or pass the permissions manually:
```bash
deno run --allow-run=node --allow-write=. jsr:@jlarky/determine-package-type
# or
deno run --allow-run=node --allow-write=some-folder/.determine-type.js jsr:@jlarky/determine-package-type some-folder
```