Code With Wolf


Windows Subsystem For Linux

Windows Subsystem For Linux

I'm a full stack web developer who spends most of my time in the javascript ecosystem. I know my way around NPM and node, but I discovered that my co-workers and friends who use Mac and Linux systems don't have many of the npm issues that I face on windows.

NPM Issues on Windows

This could quickly become a lengthy list but I run into more npm install issues than non-windows users. I also run into deeply nested file system issues. Why should npm care where files are stored and cached on your machine?

How I have fixed this

I haven't had an NPM issue in quite some time now that I felt was related to my operating system, and I credit it to two things that I have done as a javascript developer on windows.

1. I use NVM

I now use Node Version Manager, nvm. I can control which versions of node and npm are running on my machine at any time and which versions are deploying. I write more about this in this article.

2. I use Windows Subsystem for Linux

This allows me several benefits. Instead of using powershell or cmder and using my windows machine, WSL allows you to run a linux machine on your computer. I don't run into the long nested file system issues on npm installs that can be common with windows (or installs failing with an ambiguous error message and no particular reason). I also can run locally just as I would deploy my projects, on a cheaper linux machine than windows (or having to set up Docker... which is fine... but why mess with it if you don't need it for smaller hobby projects).

How to set up WSL

Set up is as easy as 1-2-3.

  1. Go to your Control Panel and navigate to Turn Windows Features On or Off. You can get there from clicking the uninstall a program link and it should be on the left side nav.
  2. Activate the Window Subsystem for Linux option.
  3. Go to Microsoft Store and install free version of the linux distibution you'd like. I use Ubuntu, but they have Kali and others.

You now have an Ubuntu or other linux distribution set up with a command line. You will need to log in (or create an account) but after that when you use that command line you are interacting with the linux machine that you just installed on your computer.



© 2022 Code With Wolf