Published Aug 09 2018
Psssst! The 2023 WEB DEVELOPMENT BOOTCAMP is starting on FEBRUARY 01, 2023! SIGNUPS ARE NOW OPEN to this 10-weeks cohort course. Learn the fundamentals, HTML, CSS, JS, Tailwind, React, Next.js and much more! ✨
There are basically two ways to reference the current folder in a Node.js script:
./, there is
../, which points to the parent folder. They behave in the same way.
There is a big difference between the two.
./ will give you the current working directory. It will return the same result as calling
Initially the current working directory is the path of the folder where you ran the node command, but that can be changed during the execution of your script, by using the
There is just one place where
./ refers to the current file path, and it’s in a
require() call. In there,