A few node packages have been causing me pain lately. Who knew that my Windows 10 addiction can get me into trouble with node?
There are, of course, multiple ways to solve the node problem on Windows.
Do not use the offending package :).
If there is no support for Windows, your great program does not get written using the specific package. Hell, yeah.
Use NVM to juggle between node versions and check whether the problem goes away.
I did something similar when using strapi-js. I could not get it to work on Node 10 or 11.
Try using Git Bash or something similar.
Or, hop on to the train to Linux - Windows Subsystem for Linux to be specific
I live life on the edge - so, Linux.
Enable WSL & Install Linux within Windows
First, go ahead and enable WSL.
- Go to Control Panel\Programs\Programs and Features
- Select “Turn Windows features on or off” on the left navigation link
- Check “Windows Subsystem for Linux” to install
Next, you have to choose a Linux distribution to install. You can do that quite easily by going to Start Menu > Microsoft Store > Search for “Linux”.
Select a Linux distribution and click ‘Get’ to install.
Alas, it was not that simple for me. Windows Store was stuck in a loop and refused to install any app. Multiple rounds of reset, clearing cache etc did not help. Therefore I did the next best thing - left that problem for another day, and followed an alternative.
- Download the Debian distribution for WSL from Microsoft Site.
- Click on the file to run the Debian installation. Provide a user id/password for Linux when prompted
Configure Linux in Windows
Once the Linux installation is complete, it is time to configure the app.
Click on Start > Debian GNU/Linux to start the Debian shell. You can use the default command shell by playing around with the command prompt options.
Alternatively, use the following line to start bash in Cmder (or in your favorite emulator).
%windir%\system32\bash.exe ~ -cur_console:p
In the bash prompt, update package versions.
sudo apt update
You will have a problem in using wget and other such utilities with https protocol. An example of error below.
ERROR: The certificate of ‘curl.haxx.se’ is not trusted.
Run the below command to install trusted certificate providers.
sudo apt-get install ca-certificates
You can find the latest version of curl by going to [https://curl.haxx.se/download/] and use wget to get latest version and build locally. I am lazy and used apt to get an older version.
sudo apt install curl
Get latest node.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
And, install node.
sudo apt install nodejs