Skip to content

Commit 3471d52

Browse files
infinnieclaudiahdz
authored andcommittedNov 14, 2019
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 dbbf977 commit 3471d52

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)
Please sign in to comment.