visual studio code CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory - npm

I am new to javaScript, trying to set up Visual Studio Code.
I have installed NodeJs and Visual Studio Code, with windows Powershell.
In visual studio > terminal if I run npm view command I am getting following error
CMD .EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
npm ERR! Invalid package
Can anyone please take a look at this issue. Is this because of restrictions on corporate systems?

It looks like your project directory (and your profile) is stored on a network fileshare, which is quite common in corporate environments.
You can ask your IT to create a mapped drive with your profile, or you can use the pushd command to create a temporary mapping.
Before opening the project in Visual studio run this from your command line (replace the path with your actual UNC path):
pushd \\corpserver\share$\jdoe\projects\java\...
the command will place you in the newly created temporary drive.
Copy the new temporary path
Open Visual Studio Code and open your project from this temporary path
You should now be able to use terminal and build/run scripts

In my case, I forgot to install NodeJS in WSL. Then, node was taken from Windows.
> which node
/mnt/c/Program Files/nodejs/node.exe
Installing NodeJS on my WSL did the trick
> sudo apt-get install nodejs

Related

Visual Studio 2022: Cannot create a project named "tempProjectCreation" because of npm naming restrictions

I'm trying to create a new Typescript project in Visual Studio 2022 Community Edition.
I've installed Visual Studio 2022 Community Edition (Windows), as well as Node.JS v18.12.1-x64 for Windows.
In the Visual Studio Installer (v17.4.2) I clicked the "Node.js development" workload and installed it.
I then opened Visual Studio 2022 Community and clicked "Standalone Typescript React Project" from the "Create New Project" page.
While creating the project, a command window opens and the following error occurs in a command window (cmd.exe) that was launched from Visual Studio:
C:\Program Files\nodejs\npx.cmd --yes create-react-app "C:\Users\Admin\source\reactproject1\tempProjectCreation" --use-npm --template typescript && cd /D C:\Users\Admin\source\reactproject1\tempProjectCreation && npm i --save-dev jest-editor-support eslint-config-react-app
Cannot create a project named "tempProjectCreation" because of npm naming restrictions:
* name can no longer contain capital letters
Please choose a different project name.
Press any key to continue . . .
The IDE fails to create the new react template site. Apparently Node.js now forbids Uppercase for file portability reasons.
The solution would seem simple (as the error points out) - simply change the name of "tempProjectCreation" to "tempprojectcreation" (lowercase) and it should work. In fact, I executed the "npx.cmd" command above and renamed the tempProjectCreation to tempprojectcreation" and the website generated without issue!!
I have googled and searched my hard drive and cannot find the Visual Studio template script that might be invoking the error. In fact, I can't find where Visual Studio Template scripts are stored from my
Where are the Visual Studio Template scripts? I've looked in "C:\Users{UserName}\AppData\Local\Microsoft\VisualStudio\17.0_0d978569 and they don't appear to be there.
Are they editable? Is it possible to change the "tempProjectCreation" to lowercase "tempprojectcreation"?
As this is a configuration question, I'm not sure if I am missing any debug information besides the error emitted above, but I'll edit this question if necessary.
here are the steps that I've taken in order to be able to create a standalone React Typescript project with Visual Studio 2022 (on Windows):
open a windows console (cmd) and uninstall then locally reinstall the create-react-app :
npm uninstall -g create-react-app
npm install -g create-react-app
Navigate to this folder: C:\Users\[your_ username]\AppData\Roaming\npm\node_modules\validate-npm-package-name
Edit index.js and comment out these lines of code:
if (name.toLowerCase() !== name) {
warnings.push('name can no longer contain capital letters')
}

Where is cmake located when downloaded from visual studio 2022

Where is cmake located when downloading it from visual studio 2022 as I wanted to add it in environmental variables
Launch the Native Tools Command Prompt (accessible via the Start Menu). From here you can run:
> where cmake
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
to determine the location. I expect that for VS2022 the path will be very similar.
However, the version of CMake distributed with Visual Studio has patches from Microsoft. You should either install upstream CMake for use outside of the Native Tools Command Prompt, or just use the Native Tools Command Prompt.

Microsoft.VisualStudio.Tools.Office.targets missing

I am installing a build agent on a virtual machine (using GoCD) and my goal is trying to keep it as light as possible, i.e., installing only MSBuild and avoid installing visual studio.
One of my projects uses OfficeTools and when compiling the build I get the following error:
C:\GoAgent1\pipelines\ProjectRepo\Office\MyProject.Office.Excel2007.UnderwritingNotes\MyProject.Office.Excel2007.UnderwritingNotes.csproj(365,3):
error MSB4019: The imported project "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
OfficeTools\Microsoft.VisualStudio.Tools.Office.targets doesn't exist!
For that I will need to install "Office Tools for Visual Studio" which depends on Visual Studio (in this case VS2015 or 14.0).
One solution is copying this folder from my development machine but is sounds a bit messy!
So I was wondering if there are standalone versions that I can plug into MSBuild without installing Visual Studio. Any suggestion?

'npm' is not recognized as an internal or external command error in Developer Command Prompt for VS2015

I am trying to execute npm install –g tsd in Developer Command Prompt for VS2015.
But it returns
'npm' is not recognized as an internal or external command,
operable program or batch file.
Any idea?
To solve this issue in Visual Studio 2017 (and above), make sure to install the NodeJS tools in the VS installer.
To launch it, go to Control Panel -> Programs -> Programs and Features, scroll down to Visual Studio 2017 and click Change.
Choose Modify in the installer.
Check the Node.js development checkbox and click Modify to complete the installation.
Download / Install NodeJS tools for Visual Studio; that'll fix the issue and give you intellisense among other benefits!
https://github.com/Microsoft/nodejstools
This solution is specifically for Visual studio code editor.
The easiest way to solve that, is to install plugin for node.js using VS code editor,
To do that follow the steps.
click on Extension Icon, and type in search box node.js, It will give you search result.
Look for the node.js Extension pack.
It should look like the bellow screen, I have already install, the extension. That is why, the green install button is not visible, Just hit on install, once finished. Restart the VS code. now it should work for sure.
You can install Node.js from https://nodejs.org/en/. 'npm' may be unrecognized in Visual Studio 2017 and Win 10 OS when node.js package is not found. After installing node.js package, it will automatically add '..\nodejs' value in Environment variable 'PATH'. Once node.js package is installed, restart your Visual Studio 2017 to Rebuild your project again.

certmgr.exe command utility location

I'am trying to add certificate to CurrentUser location using certmgr in script:
certmgr.exe -add -r LocalMachine -s My -c -n %SERVER_NAME% -r CurrentUser -s TrustedPeople
But certmgr.exe command utility is not available in Win 7, VS2008 env.
Please tell me where and how to get.
You can find certmgr.exe by opening your visualstudio command prompt and typing in certmgr or just search for certmgr.exe in your windows explorer to know its location and use it in your script.
The location would generally be as follows:
c:\Program Files (x86)\MicrosoftSDKs\Windows\v7.0A\bin
The above location is when you have installed VS.NET 2010 using hte default location during installation.
Here are steps if you don't have Visual Studio installed. Should work for Windows 7+ (tested on Windows 10).
Install Windows 10 SDK (download).
Copy certmgr.exe from C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86.
You can then use certmgr.exe on any computer without installing the SDK. Not sure about redistribution license though.
There is also a x64 version, but as far as i can tell x86 version also works for x64-bit machines.
rundll32.exe cryptext.dll,CryptExtAddCER "path_to_*.crt_file" should do the trick, then just hit next on a few popups, hard to make silent though, you may have some luck puttng the .crt in location already and merging a .reg from command line, that might be silent.
You're talking about certmgr.exe and certmgr.msc, which are different things. However, about the .exe:
This tool is automatically installed with Visual Studio and with the Windows SDK.
(from the documentation)
So reinstall Visual Studio, or download the Windows SDK.