# import2require

> Convert `import foo from 'foo'` to `const foo = require('foo')` from the commandline

Latest version **0.2.1** (published 2020-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install import2require
pnpm add import2require
yarn add import2require
bun add import2require
```

Provides the command `import2require`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2020-06-23 |
| First published | 2020-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | pixelastic |

## Links

- npm: https://www.npmjs.com/package/import2require
- npm.io page: https://npm.io/package/import2require

## Dependencies (2)

- [firost](https://npm.io/package/firost.md) 1.5.1
- [golgoth](https://npm.io/package/golgoth.md) 1.2.0

## Recent versions

- 0.2.1 (latest) — 2020-06-23
- 0.2.0 — 2020-06-22
- 0.1.5 — 2020-06-22
- 0.1.4 — 2020-06-22
- 0.1.3 — 2020-06-15
- 0.1.2 — 2020-06-15
- 0.1.1 — 2020-06-15
- 0.1.0 — 2020-06-15

## README

# Import2require

Command-line tool to convert `import` and `export` statements in JavaScript
files to `require` and `module.exports` instead.

This tool is meant to be used when you need to convert a codebase from one style
to the other.

## Example

```javascript
// This code...
import absalom from 'absalom';
import westcrown from './westcrown.js';
import { sandpoint, magnimar } from 'varisia';
import { nisroch, ridwan } from 'nidal';

export default {
  world: 'golarion',
};

// ...will be converted to
const absalom = require('absalom');
const westcrown = require('./westcrown.js');
const { sandpoint, magnimar } = require('varisia');
const { nisroch, ridwan } = require('nidal');

module.exports = {
  world: 'golarion',
};
```

## Usage

Install `import2require` locally or globally, then run `import2require
./path/to/files.js`. Make sure you backup your files before running it, just in
case.

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