# naked-json-require

> Single function to "require" json file that lacks an extension

Latest version **1.0.1** (published 2016-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install naked-json-require
pnpm add naked-json-require
yarn add naked-json-require
bun add naked-json-require
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-02-07 |
| First published | 2015-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dan MacTough |
| Maintainers | danmactough |
| Keywords | json, require |

## Links

- npm: https://www.npmjs.com/package/naked-json-require
- Repository: https://github.com/danmactough/naked-json-require
- Homepage: https://github.com/danmactough/naked-json-require#readme
- Issues: https://github.com/danmactough/naked-json-require/issues
- npm.io page: https://npm.io/package/naked-json-require

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-02-07
- 1.0.0 — 2015-10-14

## README

# naked-json-require
Single function to "require" json file that lacks an extension

## Usage

```js
var json = require("naked-json-require");
var config = json("./path/to/some/json");
```

## Why?

Generally, you can simply `require` any json file. But in node, if you try to do
that with a json file that doesn't have a `.json` file extension, it will fail
with the error:

```
SyntaxError: Unexpected token :
```

This is because the node module loader assumes that a file without an extension
is a `.js` file, and tries to use the `.js` module loader. See:
https://github.com/nodejs/node/blob/master/lib/module.js#L354

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