path.join in nodejs
path.join() does two things :
- Joins all given path segments together using the platform specific separator as a delimiter
- Normalizes the resulting path
Here, it normalizes the path by removing extra
path.join('src/', 'js/Router.jsx'); 'src/js/Router.jsx' on OSX and Linux 'srcjsRouter.jsx' on Windows
Recommended way to use
path.jointo make it work across platform.
Note that we are just specifying the folder (or directory) name. And let
path.join(__dirname, 'src', 'js', 'Router.jsx');
path.joinadd OS specific separators.