Problem with using node.js on VSC with Windows - node.js

My laptop is 64-bit operating system, Windows 10
I have installed Node.js for Windows (version v12.17.0)
I have installed code.runner on VSC as well
However, the error msg
"Command 'node' not found, but can be installed with:
sudo apt install nodejs"
keep appearing. I have no idea what is wrong.
Will changing the user settings or workspace settings help ?

The problem is that you have not set the Path in the Environment Variables.
In Windows, search for "Environment Variables".
Open Environment Variables.Open Path and add the PATH : C:\Program Files\nodejs\bin
By default, the installer uses the Node.js distribution in C:\Program Files\nodejs. If node is installed in C:\Program Files\nodejs directory, then add the PATH in in window's PATH environment variable as C:\Program Files\nodejs\bin.
Restart any open command prompts for the change to take effect.

Related

Changing CAPACITOR_ANDROID_STUDIO_PATH in Arch Linux

I'm trying to set up my development environment for CapacitorJS on Arch Linux.
I followed the documentation and added
CAPACITOR_ANDROID_STUDIO_PATH=/usr/bin/android-studio
to my systems environment variables (not the project) but I'm still getting the same error
[error] Unable to launch Android Studio. Is it installed?
Attempted to open Android Studio at:
/usr/local/android-studio/bin/studio.sh
You can configure this with the CAPACITOR_ANDROID_STUDIO_PATH
environment variable.
Even though It's never pointed to /usr/local/android-studio/bin/studio.sh
I ran whereis android-studio and got android-studio: /usr/bin/android-studio, so I thought that would be the correct path, but every time I run npx cap open android it says it's trying it launch from the same path and never changes
It depends how you've installed it, for example Toolbox installs it inside the user's home directory.
nano ~/.bashrc
export CAPACITOR_ANDROID_STUDIO_PATH=~/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/bin/studio.sh
locate studio.sh might be able to find it, too.

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]

How to open VSCode from a Windows Linux Subsystem?

I have VSCode installed on my host OS which is Windows 10 on which I have an Ubuntu Subsystem terminal (WSL) and I'm trying to open VSCode from whitin it with this command code . The problem is that the output is Command 'code' not found. How can I make this work?
Assuming you have installed VSCode in its default place, then in WSL you can do :
PATH="$PATH:/mnt/c/Users/your-user-name/AppData/Local/Programs/Microsoft VS Code"
and run code.exe .
First, try installing the Remote - WSL extension in VSCode (or the meta Remote Development extension pack, which includes the WSL work).
I doubt that's your main problem, but it could help.
Next, try running code . under PowerShell - Does that work? If not, then VSCode isn't in the Windows path. Try reinstalling it -- If it's not in the path, some other associations may not be correctly installed either. I don't recall if there's an option during installation to add or not add it to the Windows path, but if so, it could be that it was deselected during installation.
If it does launch in Windows, then obviously it's in the Windows path. By default, WSL appends the Windows path to the default path in Ubuntu during init. So (again, by default) code . should work in WSL if it is working under PowerShell.
Check your $PATH under Ubuntu (echo $PATH). Is the .../Microsoft VS Code/bin directory (wherever it is installed) in the path? If not, then WSL may not be doing its default append. Edit /etc/wsl.conf under Ubuntu and look to see if there's an [interop] section, as in:
[interop]
appendWindowsPath=false
If so, then change it to true (or, delete it entirely) to allow WSL to add the Windows path. While it's the default setting if missing, you might try adding it and setting it to true (although that shouldn't have any effect).
If that still doesn't work, then check your startup scripts (e.g. .profile, .bash_profile, .bashrc) to see if there are any modifications to the PATH which could be causing this problem.

I cannot reinstall node.js on windows 10

I need help reinstalling node.js but I keep this error when I uninstall the previous node
The Windows Installer Service could not be accessed.
This can occur if you are running Windows in Safe mode or if the Windows Installer is not correctly installed
I then try reinstalling msiexec.exe to see if I can fix the error in the windows installer but this popped up
ren msi.dll msi.old
ren msiexec.exe msiexec.old
bash: cd: %windir%system32: No such file or directory
The window installer service is running I check and I try using other packages like chocolatey but I still get the error (Generic MSI error).
As a last resort, I deleted the node folder from the program file but that didn't work. please I need help saving this
I got the error too
This is how i solved it
1-) I ran your command line as administrator then
2-) I typed sfc /scannow in cmd and entered
I fixed this by downloading the latest nodejs zip file and then edit the environment variable by adding C:\Programs Files\nodejs.Note: add the content of the zip file to C:\Programs Files\nodejs Thanks
Try running the installer as an admin.
Run command prompt as administrator and type in this code sfc /scannow the wait for it to finish repairs and try again

Where to see list of programs installed via command prompt?

I am new to windows and recently installed angular with the following steps,
- 1> Downloaded and installed Node, -2> Used npm install -g angular/cli, via command prompt. My question here is - I could see Node.js in the list of installed programs in control panel, I am not seeing angular here. I referred to the PATH environment variable where I could see path for Node.js but no path was specified for angular. Where will I be able to see the programs installed via command prompt ?
I referred google and did thorough exploration of my windows system

Resources