addyosmani / addyosmani/es6-equivalents-in-es5
CommonJS Require example; path vs module
Open
- Dominant language
- No language data
- Stars
- 2.5k
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
In Node/CommonJS when you `require('lib/math')` you are requiring `math.js` from a module named `lib`. This can be a point of confusion for newbies since it seems like you are requiring from a local path.
``` js
var math = require('lib/math');
console.log('2π = ' + math.sum(math.pi, math.pi));
```
The above might be clearer if it used either of these require paths:
``` js
require('./lib/math.js') // local path
require('lodash/array/chunk.js') // node_modules path
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.