Skip to content

Commit 8026ecd

Browse files
infinnieclaudiahdz
authored andcommitted
windows: Add preliminary WSL support for npm and npx
This commit would make it possible to run `npm` installed on Windows within Windows Subsystem for Linux. It is required, however, that the end of line characters of `npm` and `npx` be `\n` for the fix to take effect. PR-URL: #253 Credit: @infinnie Close: #253 Reviewed-by: @claudiahdz
1 parent fe8e417 commit 8026ecd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

bin/npm

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ case `uname` in
88
esac
99

1010
NODE_EXE="$basedir/node.exe"
11+
if [ -x "$NODE_EXE" ] && [ -f "/bin/wslpath" ]; then # run the corresponding command prompt when Node for Windows is executed within WSL
12+
cmd.exe /c `wslpath -w "$basedir/npm.cmd"` "$@"
13+
exit $?
14+
fi
1115
if ! [ -x "$NODE_EXE" ]; then
1216
NODE_EXE="$basedir/node"
1317
fi

bin/npx

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ case `uname` in
88
esac
99

1010
NODE_EXE="$basedir/node.exe"
11+
if [ -x "$NODE_EXE" ] && [ -f "/bin/wslpath" ]; then # run the corresponding command prompt when Node for Windows is executed within WSL
12+
cmd.exe /c `wslpath -w "$basedir/npx.cmd"` "$@"
13+
exit $?
14+
fi
1115
if ! [ -x "$NODE_EXE" ]; then
1216
NODE_EXE=node
1317
fi

0 commit comments

Comments
 (0)