I'm a little confused about how to import a module in my node project. I see two ways that are working, but what is the right way; or is there any any difference? I am referring to the case where the module I'm importing is at least one directory up.
Way #1:
const myModule = require('../myModule');
Way #2:
const myModule = require('./../myModule');
Also, I see some imports are done using the file extension, and other don't. What's the correct way?
const myModule = require('./myModule');
or
const myModule = require('./myModule.js');
Any feedback will be greatly appreciated.
./refers to the current directory and../to the parent. The first is a short form of the second