Node module require deep understand it

require.resolve(‘myModel’): this behaves exactly the same as require, but does not load the file. It will still throw an error if the file does not exist. This can be use for check an package is installed or not.

 

require(‘something’);

  1. try something.js
  2. try something.json
  3. try something.node
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s