How to convert windows path to posix path using node path


dishonest

I'm developing on Windows, but need to know how to convert Windows paths (with backslashes ) to POSIX paths \with forward slashes ( /) ?

My goal is to convert C:\repos\vue-t\tests\views\index\home.vuetoC:/repos/vue-t/tests/views/index/home.vue

so I can use it in the file imported to disk

const appImport = `
import Vue from "vue"
import App from '${path}'

function createApp (data) {
    const app = new Vue({
        data,
        render: h => h(App)
    })
    return app
}`

//this string is then written to the disk as a file

I don't want to use .replace(/\\/g, '/')a string, I want to use a require('path')function.

Rajika Imal

Slash converts Windows backslash paths to Unix paths

usage:

const path = require('path');
const slash = require('slash');

const str = path.join('foo', 'bar');

slash(str);
// Unix    => foo/bar
// Windows => foo/bar

Related


How to convert windows path to posix path using node path

dishonest I'm developing on Windows, but need to know how to convert Windows paths (with backslashes ) to POSIX paths \with forward slashes ( /) ? My goal is to convert C:\repos\vue-t\tests\views\index\home.vuetoC:/repos/vue-t/tests/views/index/home.vue so I c

Using os.path for POSIX path manipulation on Windows

Vasily Prokopyev I am using Paramiko on Windows to access a remote SFTP server. I need to do some work on remote paths like os.path.join, os.path.commonprefixetc. Since my host platform is Windows, all path operations are \delimited, but I need POSIX style pat

Using os.path for POSIX path manipulation on Windows

Vasily Prokopyev I am using Paramiko on Windows to access a remote SFTP server. I need to do some work on remote paths like os.path.join, os.path.commonprefixetc. Since my host platform is Windows, all path operations are \delimited, but I need POSIX style pat

Using os.path for POSIX path manipulation on Windows

Vasily Prokopyev I am using Paramiko on Windows to access a remote SFTP server. I need to do some work on remote paths like os.path.join, os.path.commonprefixetc. Since my host platform is Windows, all path operations are \delimited, but I need POSIX style pat

Using os.path for POSIX path manipulation on Windows

Vasily Prokopyev I am using Paramiko on Windows to access a remote SFTP server. I need to do some work on remote paths like os.path.join, os.path.commonprefixetc. Since my host platform is Windows, all path operations are \delimited, but I need POSIX style pat

Using os.path for POSIX path manipulation on Windows

Vasily Prokopyev I am using Paramiko on Windows to access a remote SFTP server. I need to do some work on remote paths like os.path.join, os.path.commonprefixetc. Since my host platform is Windows, all path operations are \delimited, but I need POSIX style pat

Convert Mac path to posix in python

Alexander grass I'm stuck trying to convert Mac paths to POSIX paths in Python. I want to convert something like this: 'Main HD:Users:sasha:Documents:SomeText.txt' To this: '/Users/sasha/Documents/SomeText.txt' I know that I can simply split the string into

Convert Mac path to posix in python

Alexander grass I'm stuck trying to convert Mac paths to POSIX paths in Python. I want to convert something like this: 'Main HD:Users:sasha:Documents:SomeText.txt' To this: '/Users/sasha/Documents/SomeText.txt' I know that I can simply split the string into

Convert Mac path to posix in python

Alexander grass I'm stuck trying to convert Mac paths to POSIX paths in Python. I want to convert something like this: 'Main HD:Users:sasha:Documents:SomeText.txt' To this: '/Users/sasha/Documents/SomeText.txt' I know that I can simply split the string into

Convert Mac path to posix in python

Alexander grass I'm stuck trying to convert Mac paths to POSIX paths in Python. I want to convert something like this: 'Main HD:Users:sasha:Documents:SomeText.txt' To this: '/Users/sasha/Documents/SomeText.txt' I know that I can simply split the string into

Convert Mac path to posix in python

Alexander grass I'm stuck trying to convert Mac paths to POSIX paths in Python. I want to convert something like this: 'Main HD:Users:sasha:Documents:SomeText.txt' To this: '/Users/sasha/Documents/SomeText.txt' I know that I can simply split the string into

Convert Mac path to posix in python

Alexander grass I'm stuck trying to convert Mac paths to POSIX paths in Python. I want to convert something like this: 'Main HD:Users:sasha:Documents:SomeText.txt' To this: '/Users/sasha/Documents/SomeText.txt' I know that I can simply split the string into

Convert posix path to windows (terminal or script) in git bash?

slow down Some programs/libraries on Windows only require the Windows path. So from the git bash terminal I had to do: $ export FOO="d:\\path\\to\\folder" Is there an alternative? Feng I 've seen commands used (eg, Git itself ) .cygpath Convert Unix and Windo

Convert posix path to windows (terminal or script) in git bash?

slow down Some programs/libraries on Windows only require the Windows path. So from the git bash terminal I had to do: $ export FOO="d:\\path\\to\\folder" Is there an alternative? Feng I 've seen commands used (eg, Git itself ) .cygpath Convert Unix and Windo

Convert posix path to windows (terminal or script) in git bash?

slow down Some programs/libraries on Windows only require the Windows path. So from the git bash terminal I had to do: $ export FOO="d:\\path\\to\\folder" Is there an alternative? Feng I 've seen commands used (eg, Git itself ) .cygpath Convert Unix and Windo

Convert posix path to windows (terminal or script) in git bash?

slow down Some programs/libraries on Windows only require the Windows path. So from the git bash terminal I had to do: $ export FOO="d:\\path\\to\\folder" Is there an alternative? Feng I 've seen commands used (eg, Git itself ) .cygpath Convert Unix and Windo

Convert posix path to windows (terminal or script) in git bash?

slow down Some programs/libraries on Windows only require the Windows path. So from the git bash terminal I had to do: $ export FOO="d:\\path\\to\\folder" Is there an alternative? Feng I 've seen commands used (eg, Git itself ) .cygpath Convert Unix and Windo

How is "/path/file/.." compatible with POSIX?

action I want to change the current directory to a shell script directory containing specific regular files. I found the following tricks to work with mkshand busybox sh: path=/path/to/regular/file cd $path/.. but not in GNU Bash: bash: cd: /path/to/regular/

How is "/path/file/.." compatible with POSIX?

action I want to change the current directory to a shell script directory containing specific regular files. I found the following tricks to work with mkshand busybox sh: path=/path/to/regular/file cd $path/.. but not in GNU Bash: bash: cd: /path/to/regular/

How is "/path/file/.." compatible with POSIX?

action I want to change the current directory to a shell script directory containing specific regular files. I found the following tricks to work with mkshand busybox sh: path=/path/to/regular/file cd $path/.. but not in GNU Bash: bash: cd: /path/to/regular/

How is "/path/file/.." compatible with POSIX?

action I want to change the current directory to a shell script directory containing specific regular files. I found the following tricks to work with mkshand busybox sh: path=/path/to/regular/file cd $path/.. but not in GNU Bash: bash: cd: /path/to/regular/

How is "/path/file/.." compatible with POSIX?

action I want to change the current directory to a shell script directory containing specific regular files. I found the following tricks to work with mkshand busybox sh: path=/path/to/regular/file cd $path/.. but not in GNU Bash: bash: cd: /path/to/regular/

Convert Windows path to Linux

Ernil Uzbek: I created a CSV file ( driving_log.csvwith a file path for each image created by my emulator), but I was using my brother's Windows computer when I did this, so now the file path looks like this for each image (And almost 14,000 people). When I ca

Convert Windows path to Linux

Ernil Uzbek: I created a CSV file ( driving_log.csvwith a file path for each image created by my emulator), but I was using my brother's Windows computer when I did this, so now the file path looks like this for each image (And almost 14,000 people). When I ca

Convert Windows path to Linux

Ernil Uzbek: I created a CSV file ( driving_log.csvwith a file path for each image created by my emulator), but I was using my brother's Windows computer when I did this, so now the file path looks like this for each image (And almost 14,000 people). When I ca