Here I’m going show you how to use static assets in node js and express with the help of importing path library.
For example let’s say you have public folder in your project and you want to access all files and folder inside this and you to create one static assets for accessing this.
First of you need to import your path library such as
const path = require(‘path‘);
After importing library you can load or define static assets such as
//load static variable
same way you can access public inside folder such as