Skip to content

Commit

Permalink
windows: Add preliminary WSL support for npm and npx
Browse files Browse the repository at this point in the history
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
  • Loading branch information
infinnie authored and claudiahdz committed Nov 14, 2019
1 parent dbbf977 commit 3471d52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/npm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ case `uname` in
esac

NODE_EXE="$basedir/node.exe"
if [ -x "$NODE_EXE" ] && [ -f "/bin/wslpath" ]; then # run the corresponding command prompt when Node for Windows is executed within WSL
cmd.exe /c `wslpath -w "$basedir/npm.cmd"` "$@"
exit $?
fi
if ! [ -x "$NODE_EXE" ]; then
NODE_EXE="$basedir/node"
fi
Expand Down
4 changes: 4 additions & 0 deletions bin/npx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ case `uname` in
esac

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

0 comments on commit 3471d52

Please sign in to comment.