slash-to-regexp Convert path with slash into regexp. Installation npm install slash-to-regexp Usage const slashToRegexp = require('slash-to-regexp'); slashToRegexp('node_modules/core-js');// output /node_modules[\\/]core-js/ slashToRegexp('node_modules\\\\core-js', 'g');// output /node_modules[\\/]core-js/g slashToRegexp('/node_modules/decimal.js/');// output /[\\/]node_modules[\\/]decimal\.js[\\/]/