Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What require('./.'); means?

Found this strange looking URL which is working by the way.

var _ = require('./.');

Can someone explain what this will do in reality and why they are doing it ?

like image 548
Hivaga Avatar asked Nov 27 '25 18:11

Hivaga


1 Answers

It may be a typo, but it is normalized to ..

If you're ever curious about how a path is resolved in Node.js, you can use path methods and require.resolve to see what is going on.

> path.normalize('./.')
'.'
> path.normalize('././././././././.')
'.'
> require.resolve('./.') // assuming `index.js` exists...
'/path/to/index.js'
like image 151
snek Avatar answered Nov 29 '25 13:11

snek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!