UNPKG

916 BMarkdownView Raw
1# require-from-string [![Build Status](https://travis-ci.org/floatdrop/require-from-string.svg?branch=master)](https://travis-ci.org/floatdrop/require-from-string)
2
3Load module from string in Node.
4
5## Install
6
7```
8$ npm install --save require-from-string
9```
10
11
12## Usage
13
14```js
15var requireFromString = require('require-from-string');
16
17requireFromString('module.exports = 1');
18//=> 1
19```
20
21
22## API
23
24### requireFromString(code, [filename], [options])
25
26#### code
27
28*Required*
29Type: `string`
30
31Module code.
32
33#### filename
34Type: `string`
35Default: `''`
36
37Optional filename.
38
39
40#### options
41Type: `object`
42
43##### appendPaths
44Type: `Array`
45
46List of `paths`, that will be appended to module `paths`. Useful, when you want
47to be able require modules from these paths.
48
49##### prependPaths
50Type: `Array`
51
52Same as `appendPath`, but paths will be prepended.
53
54## License
55
56MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)