How to install nvm for windows 10 and set up for all users - windows-10

Problem
I need to install nvm for windows 10 and have it work for my admin profile and my non admin profile. When I do all my programming it's with my regular user account. But to install things / admin stuff, I have to provide an admin account.
Details
I downloaded and ran the latest installer from this repo:
install nvm for windows 10: https://github.com/coreybutler/nvm-windows
WHen I try to run the installer, I have to use my admin account. Windows prompts me for it and after I supply the creds, the setup completes without any issues. The problem is that nvm only works when I run a command window as my admin user ... but I need to be able to run nvm as my regular non priv. user as well.
So right now, when I open a "command" window as admin, i can run
Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>nvm --version
Running version 1.1.9.
But if I run command just as my regular user,
Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
C:\Users\me>nvm --version
'nvm' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\me>
Any tips would be appreciated.
EDIT 1

Used the registry editor to add 2 new string varaibles to the regular user's profile. Can't do it through the Control Panel GUI because I'm always forced to use elevated credentials to access the control panel.
And then when I do edit the User's environment vars, it's for the admin account only.
So now when I open up a command window and run the "set" command, it includes these two variables:
NVM_HOME=C:\Users\<nonAdminUser>\AppData\Roaming\nvm
NVM_SYMLINK=C:\Program Files\nodejs
And now everything just works.

In my case it works without registry editing:
Switch to admin account
Go to nvm folder and add share it with user.
Switch to user account.
Add %NVM_HOME% and %NVM_SYMLINK% to user PATH variable
Restart cmd.

Related

getting exit status 1 when I run the command nvm use 12.18.0

I have installed nvm on my windows machine and with nvm, I installed 2 node versions but it's not letting me change the version.
Microsoft Windows [Version 10.0.16299.64]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Windows\system32>nvm use 12.18.0
exit status 1: 'C:\Users\Sarmad' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32>nvm version
1.1.7
C:\Windows\system32>nvm ls
* 15.8.0 (Currently using 64-bit executable)
12.18.0
C:\Windows\system32>nvm use 12.18.0
exit status 1: 'C:\Users\Ali' is not recognized as an internal or external command,
operable program or batch file.
Ali you are getting this error because you are installing nvm in the default location. And that is your user's directory. Nvm for windows is an attempt to port from the linux and currently does not support spaces in the path.
I spent several hours trying to figure this out and none of these solutions work for me. If you install nvm in c:\tools\ directory, (you might already have one if not just create it) should solve the problem.
UPDATE Jan - 2023
The writer of NVM for Windows has decided to deprecate it and there will be something coming up to replace it. See the announcement:
https://github.com/coreybutler/nvm-windows/wiki/Runtime
From the link:
I intend to deprecate NVM for Windows after Runtime is released. There
are two things slowing work on Runtime. First, client engagements. I
am wrapping up the most time-consuming project this quarter and will
have much more time in early spring 2023. The other thing slowing down
Runtime development is this project. So, I'm freezing feature
development on NVM for Windows.
I had the same issue in a windows environment. I solved it by running the nvm commands in the command line cmd in the root directory C:/ rather than the integrated terminal of vscode.
Run cmd as an administrator
Download the node version you want to use and use it
$ nvm download 12.18.0
$ nvm use 12.18.0
If you see the same error, you should configue the PATH in the Environment Variables like this answer is saying.
Go back to the other directory or in VsCode and try
node -v
and you'll see that you're using 12.18.0
Try to install the nvm directly in C:/ or in other folder without spaces in the PATH.
You'll need to start powershell or Command Prompt as Administrator to use nvm-windows. See here https://github.com/coreybutler/nvm-windows
Spacing in the path is the problem
you can run
nvm root and find the root folder
then copy the contents to another folder without any spaces on the path
after that move the nvm root to that folder by running the command below (with full path)
nvm root [path]

scp from Linux to Windows: 'C:\Program' is not recognized error

In my linux machine, I'm trying to send a file over to a Windows machine via:
scp fileNameA user#windowServer:fileNameA
I get the following message:
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
What's prompting this message?
I've installed OpenSSH on the windows machine, and I can successfully SSH into it. I don't want to use WinSCP, FileZilla, etc, because I have to automate this in a script. This has to be done from the Linux machine, so I'm not interested in doing pscp from the Windows machine.
I have met the same problem today.
I think it is an issue in the new version of OpenSSH, which was published few days ago. I reverted previous version (v7.6.1.0p1-Beta), which was working correctly on my VM from https://github.com/PowerShell/Win32-OpenSSH/releases and problem was fixed without any changes in configuration.
I just fixed the same problem by moving my installation of OpenSSH from C:\Program Files\OpenSSH to C:\OpenSSH.
I had to first uninstall it properly using the provided script in Win32-OpenSSH and then follow back the information provided there https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH but only changing the path to C:\OpenSSH.
I met a similar issue today, trying to copy files to a Windows server running OpenSSH-Win64. I solved the problem by adding C:\Program Files\OpenSSH, which is the recommended installation location, to the Windows path:
Open the Control Panel, go to the System and Security section and open up System.
Click on Advanced System Settings and, in the System Properties dialog box, click Environmental Variables.
In the System Variables section of the dialog box, select Path and click Edit....
Click New, add the OpenSSH folder path and click OK to apply the change.
Then, do not forget to restart the OpenSSH service, either in the service management console or by running net stop sshd, followed by net start sshd in an elevated console.

Trying to use bash on Windows and got no installed distributions message

I am trying to use bash on Windows 10, but I'm getting this message when tried to run bash:
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Windows Store:
https://aka.ms/wslstore Press any key to continue...
When I go to that url which opens the Windows Store app, there no sign of any Linux distribution there.
My windows version is(as in my right bottom corner of the screen):
Windows 10 Enterprise Insider Preview. Evaluation copy.Build
16215.rs_prerelease.170603-1840
I follow the instructions in this guide Installation Guide and also was watching this video Editing code and files on Windows Subsystem for Linux on Windows 10 from Scott Hanselman, but they didn't get the message of no installed distribution.
Any Help?
When the Windows Store opened, there was no Distro to choose, then I found this command lxrun /install and worked for me as well.
You will get something like this as an output:
C:\WINDOWS\system32>lxrun /install
Warning: lxrun.exe is only used to configure the legacy Windows Subsystem for Linux distribution.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
This will install Ubuntu on Windows, distributed by Canonical and licensed under its terms available here:
https://aka.ms/uowterms
Type "y" to continue: y
Downloading from the Microsoft Store... 100%
Extracting filesystem, this will take a few minutes...
Would you like to set the Ubuntu locale to match the Windows locale (en-FI)?
The default locale is en_US.
Type "y" to continue: y
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: <you type your login here>
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Installation successful!
Documentation is available at: https://aka.ms/wsldocs
I'm getting a similar bug after trying to uninstall and reinstall.
For me I had to open a cmd prompt as administrator and run lxrun /install
I get this when I have recently rebooted. If I wait 5 minutes, the problem fixes itself !
The top answers written for this question are more than enough. I just had trouble following them because lxrun command has been depreceated, so I get the error
'lxrun' is not recognized as an internal or external command, operable
program or batch file.
when I try to run this command with cmd.
It has been replaced with wsl command. You can get more info on this issue here - https://github.com/MicrosoftDocs/WSL/issues/425
When you run wsl /install, there is a chance you may still get the error that you had earlier posted in your question. In that case, simply go to the link https://aka.ms/wslstore as you had gone earlier. If you don't see anything coming up, simply search for Ubuntu and install the same. (If you search with the term wsl though, you will get to see other Linux flavors too and then you can download any of your choice)
It seems that the link given in the command doesn't work. Here's the actual link to the microsoft store for Ubuntu.
https://www.microsoft.com/en-nz/store/p/ubuntu/9nblggh4msv6?rtc=1
You have to go to https://aka.ms/wslstore this link and download ubuntu on windows. After that you can use bash on windows.
If you have any problems with running lxrun /install (for example on ltsb Windows version) try manual mode.
First, go to the folder with downloaded .appx file and run following commands (change filename if needed):
Rename-Item ~/Ubuntu.appx ~/Ubuntu.zip
Expand-Archive ~/Ubuntu.zip ~/Ubuntu
After finishing cd into new folder and run ubuntu.exe file. That's it.
If you get this error after installing a distribution using the windows store, and WSL was working previously, you may need to make sure that the LxssManager service is running, since it often stops after a Windows update or a reboot.
Go to services.msc, and search for LxssManager and start it; if it is running already, restart it.
For everyone who is getting
'lxrun' is not recognized as an internal or external command,
operable program or batch file.
or
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
Open microsoft store, install 'Ubuntu' then open the app. This will install ubuntu and later you can use wsl command since lxrun is deprecated
Go to add or remove programs
Install Windows subsystem for Linux
Go to https://aka.ms/wslstore, which will take you to the Microsoft Store
Select and install a Linux distribution
lxrun /install
Works on a Administrator Command Prompt for Windows 10 Professional, Version 1803 Build 17134.165
This installs GNU/Linux by default whereas there is an option to select between:
Ubuntu
openSUSE Leap 42
SUSE Linux Enterprise
Debian GNU/Linux
Kali Linux
If the given link (https://aka.ms/wslstore) works, it openes the windows store for me with an error saying something is wrong on their side and to try again later.
It's actually easier to solve this problem that other solutions listed here. If you run wslconfig /l and if the output is:
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
Just run wslconfig /s Ubuntu to set Ubuntu as default again. It should start working now.
Edit:
I've also found that if this problem occurs on a fresh boot, then you just wait for a few minutes (10 minutes max) and this error automatically disappears.
Edit 2:
I've also found that this error is sometimes also due to the corresponding service not running. Run CMD as administrator and run
net start LxssManager
For running bash on windows ubuntu is required to be installed.
As you've already added bash from programs and features, now you need to install Ubuntu. Contrary to what is seen in most of the installation guides on web, it does not gets installed by running 'bash.exe'.
You can simply go to Microsoft store in search for 'Bash' or 'Ubuntu'and install Ubuntu 18 LTS from there.
After installation you'll be able to use the terminal and all its commands.
Run the bash command in git bash windows. It worked !!
As of 2022, New Linux distributions are available for Windows 10 as well as Windows 11 like Kali Linux and Ubuntu. Both available from Microsoft Store. Someone watching this question now can visit Microsoft Store to Download them..
I had this same issue. But when you go to the windows store you can search for ubuntu and then install the ubuntu app and it works. I think most of the tutorials on the net are from the beta version and have afterwards never been updated.
https://insights.ubuntu.com/2017/07/11/windows-10-loves-ubuntu-loveislove/
Note: This is also old. You do not need to be on the insider builds. I'm not and it worked.
The only thing that worked for me is described here https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distros
https://aka.ms/wsl-ubuntu-1804
manually install it or run Add-AppxPackage.\.appx from PowerShell
The link to the store appears to have a region lock in it, resulting in errors for many visitors.
However there are different Ubuntu distributions to be downloaded. See image below, image is however in Dutch but it will show results.
So pick a version you desire and it will result in a working bash.
The actual answer to the question query is: The user exists with Ubuntu already installed. But WSL command does not find anything in CMD.exe "Command Line" "System does not find distribution."
You need to start the below WSL command from Windows Start Menu. And then the old Linux System will show up on WSL in the command line as found.
If this doesn't work for you? Just start up PowerShell with Administrator and:
WSL --help
WSL "only this command, will start the Linux default distro selected"
You can then start up using this command with CMD.exe Administrator in Windows:
lxrunoffline l "This will now list all your distros"
With an option to remove old distros copied to Windows folders are with perhaps Ubuntu18.04 such way that you will have to use Linux to remove older folders, do not try to copy or edit files in a distro with Windows Apps. You risk integrity problems as well as many errors followed by huge processing time. Use folder /mnt to find your drive with Linux and use commands there to further finish your work as perhaps copying the home directory into a new distro.
My solution to move "not copy" my distro then was: "to give space for C:"
lxrunoffline m -n Ubuntu-18.04 -d d:\wslinstalled\Ubuntu-18.04 "remember folder names"
"Remember folder name such as Ubuntu-18.04 for a specific movement. Unless you will overwrite everything on that folder name with also the lxrunoffline files and you risk losing older copies if you use one folder name. You might end up with a strange name to your project if you just use one directory."
Lxrunoffline has several other commands if you need help just run:
lxrunoffline
like beginner_ said in his answer you need to go to the store and look for the distros you want to install.
Please see the following link to understand what has changed and what you can excpect or what distros you can look for(the list is outdated so just try to find an updated list or just try your luck).
I am running on my machine without the developer mode Ubuntu, OpenSuse and Kali.
Access to Microsoft Store is blocked by my company. For me following worked in PowerShell (admin) -
lxrun /install
Go to cmd, and then run the following command:
lxrun /install
Typing lxrun /install in elevated command prompt works....
The solution to the error "WSL 2 installation is incomplete",
Execute the following steps:
wsl --install -d Ubuntu ## lxrun is no more, its now replaced with wsl,
enter image description here
wsl
enter image description here

How to enable Bash in Windows 10 developer preview?

I am using windows 10 developer preview Build 14295. From the Build conference I understood that we can enable bash in windows 10. But its not clear how to enable bash in windows 10.
Please find below the blog post for running bash in windows 10.
Link : http://www.hanselman.com/blog/DevelopersCanRunBashShellAndUsermodeUbuntuLinuxBinariesOnWindows10.aspx
After turning on Developer Mode in Windows Settings and adding the
Feature, run you bash and are prompted to get Ubuntu on Windows from
Canonical via the Windows Store
I enabled the developer mode. But I am not sure how to add a feature and run the bash. Kindly help.
To enable bash in Windows 10:
Click the Start button , click Control Panel, click Programs, and then click Turn Windows features on or off.
Enable Windows Subsystem for Linux
To get Bash installed, open Command Prompt and type “bash”
For More Information visit :
Announcing Windows 10 Insider Preview Build 14316
Run Bash on Ubuntu on Windows
In some cases, attempting to turn on Developer Mode on may crash the Settings app. If this happens, the workaround is to use these steps here to enable Developer Mode
The Bash feature isn't available on build 14295.
Scott answered a question that an update will be coming soon to insiders (Microsoft want to make sure everything is OK with this feature before pushing it to Insiders)
I've been chatting with a Microsoft Program Manager (Sarah Cooley) and she confirm that she have the Bash feature on Build 14311 (which isn't out for insiders yet)
You can see Scott's answer here: https://news.ycombinator.com/item?id=11394994.
Today it is available at Build 14316!
The announcement is at https://blogs.windows.com/windowsexperience/2016/04/06/announcing-windows-10-insider-preview-build-14316/
Step1: Enable Developer Mode (Settings - Update & security > For developers)
Step2: Search for “Windows Features” and choose “Turn Windows features on or off” and enable Windows Subsystem for Linux (Beta).
Step3: To get Bash installed, open Command Prompt and type “bash”
Step4: Bash will install required packages on windows you can start with windows bash
Step5: Install any package through apt-get install package_name
Happy Bash programming on windows!
Now, you don´t have to enable developer mode anymore, to run bash. Better security for you without having the dev. mode enabled.
download git bash to run bash commands on your windows file system
git-bash website

Is there a manual install of node.js for Windows 7?

I have easily installed Node.js before on Macs and other PCs, but the PC I have now at work restricts the running of .msi files.
Is there a way to manually install and configure node.js and npm on Windows 7? I have access to Powershell.
Installing nodejs (and npm) on a Windows 7 machine does not require any "magic" if you have Admin access on the target machine and do not care about setting up the expected "uninstall", various Windows performance counters, event tracing or Start menu entries.
To manually install from an existing installation on one machine to another machine, simply
Copy the entire contents of your "\Program Files\nodejs" and "\Users\USERNAME\AppData\Roaming\npm" directories as well as the "\Users\USERNAME\.npmrc" file to the same directories on target machine. (Replace USERNAME with your own Windows login name.)
Edit the "\Users\USERNAME\.npmrc" file to replace the source username with the username on the target machine.
Add "C:\Program Files\nodejs" and "C:\Users\USERNAME\AppData\Roaming\npm" to your PATH.
If you'd like to manually install direct from the MSI (without an existing installation to work from), get Scott Willeke's excellent lessmsi program, which allows you to extract all the files from any msi archive and discover all the actions taken by the Windows Installer, such as required edits to the Register, etc. (Though for nodejs, you'll only need to edit the Registry to add the proper keys to uninstall it automagically.)

Resources