nvm with WSL for projects stored in Windows - node.js

I'm struggling to understand how exactly WSL works.
The training that I'm doing requires nvm so I can manage my node versions in my project, located in my hard drive that is running with Windows.
So, in order to use nvm I need WSL, but I cannot comprehend where it is located. As far as I understood (and I'm pretty sure that I'm wrong) the WSL that I installed is like a Linux VM, completely independent from my Windows, and I operate it through the Ubuntu Terminal that came with WSL. If that's the case, how can nvm in WSL be useful if my project is in my Windows directory and the WSL controls node versions from my Linux VM?
How do I make nvm useful for my project running from my C:\ drive and how does WSL work with nvm in my Windows?
Thank you!

A few options, but each has advantages and disadvantages:
If your Node/JavaScript files are on your Windows C:\ drive, then you do have the ability to access that from WSL. Windows paths are automatically mounted and accessible in WSL via /mnt/c, /mnt/d, etc.
So if you have your JS source in, for example:
C:\Users\<myusername>\Documents\Projects\JS_class\project1\
Then that would be accessible under Ubuntu in WSL via:
/mnt/Users/<myusername>/Documents/Projects/JS_class/project1/
The disadvantage here is performance, as mentioned in this question.
Alternatively, you can store your project files inside WSL. You can access the WSL path from Windows by using \\wsl$\Ubuntu\home\<yourusername>\ (or similar). You can use this to copy from your existing Windows drive to your WSL distribution.
Advantage: Faster. Disadvantage: Unknown -- You seem to want the files to be in Windows, but I'm not sure why.
Or you can use WSL1 for most Node/JS tasks. See the previously mentioned answer for details on how to convert.
Advantage: Speed
Disadvantage: WSL1 hasn't been updated in a while, and is started to run into some compatibility issues. It's still popular enough and stable enough at the moment for me to continue to recommend it, though.
There's also a Windows version of nvm as well as a replacement project that the repo there mentions. I cannot personally speak for the quality of it, but it does have 23k stars on Github. Note that it is not affiliated with the original (Linux-based) nvm project.

Related

How to develop Linux + Windows application with WSL2 and Visual Studio C++ 2019 using the same vcpkg dir?

recently I started to use WSL & vcpkg, but it has some problems when mixing windows + linux development.
It seems like that installing Linux packages or Windows packages with vcpkg, mutually damage the vcpkg configuration and then vcpkg roughly says: "the package you want to install doesn't exist". (I know for sure that it exist)
If it matters, the project is located in the windows "world" so the WSL directing to it with /mnt/c/Users//workspace/proj1
but it really doesn't matter.
Does Anyone already encountered this problem?
Am I doing something wrong?
Is there a better way to develop a cross-platform project?
Thanks
So I post it to help anyone who have doubts about it:
Don't mix WSL project with windows project because it will force you to work on the windows filesystem from WSL. (WSL can work on the windows filesystem with /mnt/)
anyway, It will both corrupt the vcpkg and the overall compile times will be horribly slow from linux filesystem (usually ext4) to the windows filesystem (NTFS).
this is my original post in the Github:
https://github.com/microsoft/vcpkg/issues/13948#issuecomment-706625438

Shared folder between Windows host and Ubuntu guest, long filenames

I'm setting up an Ubuntu guest under Windows using VirtualBox for a colleague to provide him with a Linux-based development environment for a node.js application.
This colleague of mine can't or doesn't want to SSH into the VM and work in emacs or vim; he's a Sublime Text guy. So I have set up the project tree in a VirtualBox shared folder so he can access it from Windows (to edit) and the Linux VM (to build/test).
Unfortunately, npm install fails with file system errors. The problem seems to be extremely long path names resulting from deeply nested node_modules dependencies. I'm guessing we're hitting a Windows limit on filename length. The npm install works just fine in a regular (non-shared) directory in the VM.
Does anyone have ideas about how to deal with this problem? One idea I had was to somehow alias or link $MY_PROJECT/node_modules to another, non-shared location, but I can't figure out how to do that.
Update: I'm going to try this hack: https://www.virtualbox.org/ticket/11976.
Update 2: Ended up using samba, which is probably what I should have done in the first place.
One option is to use one of the multiple ways for sublime to edit remote files over ssh, covered in some detail here
How to use Sublime over SSH
Another is try using the native windows version of node and have your colleague develop locally directly under windows.

How to install Weechat?

I must admit i'm not much of a coder or computer scientist, but in the past a friend installed Weechat on my windows computer using Cygwin (via the Cygwin terminal of course). I have a new computer now thats running windows 8.1 and have installed Cygwin with all of the necessary packages, and downloaded the latest stable version of Weechat (1.2). I am stuck from there though and don't really know which direction to move in, the only thing I have done with Cygwin so far is moved the home terminal folder to a more easier accessible location. Would it be possible to get a step by step walkthrough of how the installation progresses after downloading both the Cygwin component and the Weechat files and scripts?
Before we you can start using WeeChat, there are a few other pieces of software you need to install with CygWin. WeeChat relies on them for its functionality, which is why they are called dependencies.
You can find a detailed list of dependencies and further instructions on this link:
Weechat on Windows
Feel free to ask for further help if the above guide wouldn't suffice.
EDIT
WeeChat is currently available via the CygWin native repositories.
Simply search for weechat in the CygWin package manager.
I already have CygWin installed, what now?
No worries, simply rerun the setup-x86-64.exe* you've downloaded. This process won't remove any of your previously installed packages. At the end of the installation process you'll be able to look for and install WeeChat.
* (on 32-bit systems, the installer would be named setup-x86.exe)

at nodejs.org, is the linux tar file going to work on cygwin

I need to get node.js for a program I'm installing in Cygwin, and I'm wondering if the Linux download at nodejs.org is going to work, or does something like this for Cygwin need to be built from source? I tried downloading the linux tarball and incorporating into the installation script for Oppia (the program I'm installing) and it doesn't work, but I don't know enough about this to know what's wrong.
I suppose node.js on cygwin is not really supported. I worked with node.js under cygwin, installed with Windows installer. There are some problems, especially when there are dependencies on paths (/cygdrive/c/...). I haven't tried to build from source, but asked the guys on the node.js google group a similar question, but they just said: not supported.
So probably it's better to write those unbelievable ugly .bat/.cmd scripts and use the DOS shell commands when working with Windows (which I hate so much). I tried to use PowerShell, but it was no improvement, it's odd compared to bash.

Windows 8 + Git + Composer + SSH

So, I've been using ubuntu linux for a few months and loved it for my web dev. Everything simply works!
But I switched back to windows because linux sadly doesn't run 90% of my apps :(
So now I have a question, how do you work with git, composer and ssh on windows?
Should I setup a linux virtualbox or is it possible to be able to work comfortably without it?
"TortoiseGit" is a nice extension if you prefer some graphical support, and this needs "msysgit" to give the git commands on windows - which also brings you "git bash" if you prefer the command line. "msysgit" could be installed standalone.
SSH under Windows is always Putty. Grab the newest release 0.63, it has security fixes. To work easily with git then, you need to setup the whole public key authentication with "pageant" running in the background. Putty does a bad job configuring it to convenient levels, you have to manually add it to autostart. Or you could either use KeePass with the KeeAgent plugin to get the same (I prefer it a lot: All authentication stuff in one location).
Executing composer is a question of having installed PHP >= 5.3. If PHP is installed, you execute the alternative install command (without curl) and are nearly ready to go. Having PHP and the composer.phar in the path or add their location to the path eases things a lot.
Caveat: I have no experience with Windows 8 so far, things might be different there. My suggestions are supposed to work on Win 7 at least.
The biggest drawback of Windows is that there is no decent shell support I'd like. Having a virtual machine still is a good idea, but you need your development tools within Windows as well.

Resources