# require-path-relative

> path.relative to be used in a require statement

Latest version **1.0.1** (published 2015-05-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install require-path-relative
pnpm add require-path-relative
yarn add require-path-relative
bun add require-path-relative
```

## 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 | 2015-05-01 |
| First published | 2015-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | require, relative, path, node, js, fs, requires, nodejs, common, commonjs |

## Links

- npm: https://www.npmjs.com/package/require-path-relative
- Repository: https://github.com/mattdesl/require-path-relative
- Issues: https://github.com/mattdesl/require-path-relative/issues
- npm.io page: https://npm.io/package/require-path-relative

## 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) — 2015-05-01
- 1.0.0 — 2015-05-01

## README

# require-path-relative

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Like `path.relative(from, to)`, but normalizes it to look good in a Node `require()` statement. Also allows for an optional file entry-point.

For example:

```js
var relative = require('require-path-relative')

relative('/modules/utils', '/modules')
=> '../'

relative('/modules/utils', '/modules', './index.js')
=> '../test.js'

relative('/modules', '/modules/utils', 'test.js')
=> './utils/test.js'

relative('/modules', '/modules')
=> './'
```

## Usage

[![NPM](https://nodei.co/npm/require-path-relative.png)](https://www.npmjs.com/package/require-path-relative)

#### `filepath = relative(from, to, [entry])`

Resolves the `from` and `to` directories, and optionally appends the `entry` file to the end of the path. 

This is handy for generating pretty-looking Node source.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/require-path-relative/blob/master/LICENSE.md) for details.

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