0

Forgive me if this has been asked, I've been googling around and searching for a few hours now.

Long story short I quite love WSL2 and Ubuntu for development. The issue I am encountering is that I sometimes need to use Windows versions of applications (like Ganache for Blockchain Development, npm/node, Android Emulator ADK) however my package management is done on WSL2.

What this means is that I have NodeJS installed, and I can access it using wsl npm, but my powershell obviously doesn't automatically prepend wsl to commands if they have a WSL2 equivalent, is there a solution for this or is the solution just to install NodeJS and such on Windows?

Thanks!

  • Zach
3
  • I'd recommend you use WSL2/bash as the main shell and call powershell as necessary. Commented Mar 28, 2021 at 14:55
  • @Philippe so the issue is something like Ganache GUI installs on Windows (I could install the GUI Linux version and run a virtual desktop but that feels overkill), or the Android ADK. Those Applications use Powershell by default to try to find npm or something similar and Powershell refuses to find them. Unless I'm misunderstanding what you're recommending is what I'm trying to setup Commented Mar 28, 2021 at 15:02
  • For NodeJS, I'd say use Windows version. Commented Mar 28, 2021 at 15:09

2 Answers 2

0

So it turns out installing everything on Ubuntu was the problem. If I install Node/Python/etc. on Windows initially Ubuntu automatically gets the Windows Paths, so installing Node/npm via NVS https://github.com/jasongin/nvs was my solution and it seems to work

Sign up to request clarification or add additional context in comments.

Comments

0

You can add WSL2 commands to Windows Powershell by using functions. Something like:

Function npm { wsl.exe npm $args }

For something to be discovered by a program, however, it needs to be a real command (see PATHEXT on what makes some file a command). Assuming you have %USERPROFILE\.bin in your PATH, you can put a script called npm.cmd there, containing simply:

@echo off
wsl.exe npm $*

(The actual Windows install of npm also makes an npm.cmd for the command to work; on mac and Linux it would be a shell script called npm. Something has got to glue between the nodejs ecosystem and the normal OS commands.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.