Use the basename
method of the path
module:
path.basename('/foo/bar/baz/asdf/quux.html')
// returns
'quux.html'
Here is the documentation the above example is taken from.
More Related Contents:
- Check synchronously if file/directory exists in Node.js
- res.sendFile absolute path
- Do you need to use path.join in node.js?
- How to close a readable stream (before end)?
- Node.js check if file exists
- Module not found: Can’t resolve ‘fs’ in Next.js application
- Get all files recursively in directories NodejS
- How to create full path with node’s fs.mkdirSync?
- Can’t resolve ‘fs’ using webpack and react
- Read file from aws s3 bucket using node fs
- How would I create a for-loop in Node.js
- What is the –save option for npm install?
- How to exit in Node.js
- Cannot overwrite model once compiled Mongoose
- ECONNREFUSED for Postgres on nodeJS with dockers
- ERR_HTTP_HEADERS_SENT: Cannot set headers after they are sent to the client
- Error handling with node.js streams
- How to separate routes on Node.js and Express 4?
- Purpose of installing Twitter Bootstrap through npm?
- TypeError: db.collection is not a function
- Express command not found
- npm ERR! Error: connect ECONNREFUSED when trying to update the npm
- Node.js Event loop
- Deploy Nodejs on Heroku fails serving static files located in subfolders
- fs.writeFile in a promise, asynchronous-synchronous stuff
- convert streamed buffers to utf8-string
- How can I save multiple documents concurrently in Mongoose/Node.js?
- Node.js – logging / Use morgan and winston
- How to reference another schema in my Mongoose schema?
- Bot framework V4 Nodejs chat history logging