Cannot create new project (VS2013 and multi-hybrid device app) - visual-studio-2013

I get the error below when I try to create a new project. I've upgraded to CTP2.
Error:
The expression """.Substring(0, 6)" cannot be evaluated. Index and length must refer to a location within the string. Paramter name:
length
C:\USERS\ME\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets
When this error occurs and I check the solution folder, no project has been created.

With VS closed, in a command window, run
npm -g uninstall vs-mda and npm -g uninstall vs-mda-targets
Check to see if this removed the vs-mda and vs-mda-targets folders under
C:\Users\YOUR-USER-NAME\AppData\Roaming\npm\node_modules\
If it didn't, you can delete those folders manually.
Then relaunch VS and create an MDHA project. It should work successfully.
If you get an error on project creation saying that the MDA targets were not found, you can manually install 'vs-mda' & 'vs-mda-targets' from under Visual Studio's Extension folder to get things working again.
Exit Visual Studio and on the drive where Visual Studio is installed, navigate to
%Program Files%\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\uxbwjkun.gjn*\packages
Here you will find two folders "vs-mda" and "vs-mda-targets"
Note that uxbwjkun.gjn will not be the exact folder name, but look for something like it that contains packages folder.
Now from here run npm -g install <full path to current folder>\vs-mda and npm -g install <full path to current folder>\vs-mda-targets
When issuing this command it's necessary to give it the explicit path to the vs-mda and vs-mda-targets folders under the VS installation in %Program Files%.
Relaunch and create a new MDHA project.

Quite a few of our devs had to solve this one on our team, so I created a script to fix this for them after the upgrade to CTP3.
It basically does what Ellen's solution does, but it does it automatically by looking up the Registry entry for the VS Extension path :)
Create a .cmd file with the following contents:
#echo off
setlocal ENABLEEXTENSIONS
echo -- Searching for MultiDeviceHybridApp Visual Studio Extension --
set KEY_NAME=HKEY_USERS\.DEFAULT\Software\Microsoft\VisualStudio\12.0\ExtensionManager\EnabledExtensions
set SEARCH_VALUE=MultiDeviceHybridApp
set REG_QUERY_CMD=reg query "%KEY_NAME%" /f "%SEARCH_VALUE%"
for /f "tokens=2*" %%a in ('%REG_QUERY_CMD% 2^>^&1^|find "REG_"') do #set RESULT_REG_VALUE=%%b
goto find_result_%ERRORLEVEL%
:find_result_0
echo Found here: %RESULT_REG_VALUE%
set PACKAGES_PATH=%RESULT_REG_VALUE%\packages
echo Installing vs mda packages....
echo.
set CMD=npm -g uninstall "%PACKAGES_PATH%\vs-mda-targets"
echo Running: %CMD%
call %CMD%
echo.
set CMD=npm -g uninstall "%PACKAGES_PATH%\vs-mda"
echo Running: %CMD%
call %CMD%
echo.
set CMD=npm -g install "%PACKAGES_PATH%\vs-mda"
echo Running: %CMD%
call %CMD%
echo.
set CMD=npm -g install "%PACKAGES_PATH%\vs-mda-targets"
echo Running: %CMD%
call %CMD%
echo.
echo Done!
goto end
:find_result_1
echo *** Could not find MultiDeviceHybridApp Visual Studio Extension path ***
:end
pause
Run this file and it should uninstall and reinstall the npm packages correctly for you!
PS. You will obviously need npm to be part of your system path.

Related

Run `flutter clean` command on each project in a directory

As a Flutter developer, I've been working on many projects. I have to work on all of them occasionally. Now those projects lie in a single directory occupying 30+ GB on my drive. It'd be a good idea to have the project's build-cache deleted to save some space. So I figured to write a script that would loop through each of them and run flutter clean inside every folder instead of running the command manually under each project's root.
After Google and StackOverflow search I came up with a command :
for /D %G in ("D:\MyProjects\*") do flutter clean "%~fG"
Well this command executes the flutter clean command for each folder like:
C:\Users\vipin>flutter clean "D:\MyProjects\Project1"
C:\Users\vipin>flutter clean "D:\MyProjects\Project2"
C:\Users\vipin>flutter clean "D:\MyProjects\Project3"
C:\Users\vipin>flutter clean "D:\MyProjects\Project4"
This should have worked since the command states to run flutter clean for each folder as it looked. Unfortunately, it didn't and threw error:
C:\Users\vipin>flutter clean "D:\MyProjects\Project1"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:\Users\vipin>flutter clean "D:\MyProjects\Project2"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:\Users\vipin>flutter clean "D:\MyProjects\Project3"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
C:\Users\vipin>flutter clean "D:\MyProjects\Project4"
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
...
Well, the pubspec.yaml files are very much present in each folder and I figured that the flutter clean command demands your prompt pointing to Project's ROOT, like below to do the job:
D:\Myprojects\Project1>flutter clean
Now I'm looking for a command/script anything to move the command's prompt to each project's root and execute the command.
Glad you asked. I had the same thought about doing it to my list of projects. The below command will do exactly what you expect. Make sure to run this from D:\MyProjects
for /d %i in (D:\MyProjects\*) do ( cd "%i" & flutter clean )

Windows Script Host Error: Invalid character - Code:800A03F6 - Source: Microsoft JScript compilation error

I'm having an issue with Powershell and CMD. When I try to execute Angular CLI commands in CMD like ng --version or ng new projectName, I get this error;
Windows Script Host Error: Invalid character
Code: 800A03F6
Source: Microsoft JScript compilation error
Update:
On Windows .js files are associated to Windows Scripting Host by default, so the script will not be run with Node.
Open a file explorer and find a JavaScript file, open the JavaScript file's properties and then "open with", select the Node.js program file to open that kind of files.
The error should stop after doing this.
This is how I solved it: (on windows 10)
Go to C:\Users\<your_username>\AppData\Roaming\npm\node_modules\#angular\cli\bin
Check for ng.js
Right click on ng.js file and click on "properties" option
You need to open it with node.exe so click on "Change" button go to node js installed directory and
(example: C:\Program Files\nodejs\node.exe)
Select node.exe
Click on OK
It should change the color of ng.js like below:
Now try ng -v and other ng commands
Installing this exact Angular version:
npm -g install #angular/cli#10.3.1
instead of the latest version:
npm -g install #angular/cli
fixed the above error.
I ran into this exact issue after updating to Angular CLI 13. Tried tons of different suggestions from other threads. What is described in the solutions here is essentially what worked for me, but I just want to point out a possible alternative method to applying the fix that doesn't associate all JS files with node.js.
Trying to execute a script from package.json on Windows throws a JScript error
In your windows system environment variables is one variable called PATHEXT. If the value contains .JS;, remove it. Then restart your CMD windows.
make sure you have proper path variable configured as shown below
Go to your system variable settings
path variable snapshot
make sure you have all these mentioned as part of path
C:\Users<userfolder>\AppData\Roaming\npm\node_modules#angular\cli
C:\Users<userfolder>\AppData\Roaming\npm
C:\Program Files\nodejs
make sure you have all these mentioned as part of path C:\Users\AppData\Roaming\npm\node_modules#angular\cli C:\Users\AppData\Roaming\npm C:\Program Files\nodejs
in my case, before npm install -g #angular/cli, the path of my system variable was:
C:\Users\AppData\Roaming\npm\node_modules#angular\cli\bin
I remove \bin and work!!!!!
Remember to fix this for the correct User
Associating .JS files to node.exe is the way to solve this.
BUT after struggling with the same issue, I wanted to add that the file association needs to be done with the same USER that you are working with the Terminal/Shell.
So if you use the Terminal as a Admin, you must login with your Admin Account just to fix the file association.
Cheers

Install pandoc with no administrator access

I'm am using rmarkdown to generate a word output and need pandoc to do so. Unfortunately I do not have administrator access on my work computer so I can't run the installer or use the install.pandoc() option.
I have tried downloading both the .zip and .tar.gz files from the github site and tried to install them manually using the "install" tab in RStudio, but get the error:
Warning in install.packages :
cannot open compressed file 'pandoc-2.2.1-windows-x86/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
Here states "If you prefer not to use the msi installer, we also provide a zip file that contains pandoc’s binaries and documentation. Simply unzip this file and move the binaries to a directory of your choice."
maybe I don't know what they mean by "move the binaries to a directory of your choice." - When I unzip the files, I still cannot access the package.
Side note - I have defined .libpaths() to allow me to install other packages, but i cannot get pandoc to work.
Any suggestions on how to do this?
Pandoc is a terminal application and does not require R-Studio to install it unziping the .tar.gz file with
linux: tar -xzvf filename.tar.gz
for windows the binary is the program pandoc itself that is unzipped from the zip file
simply unzip the file and pandoc should already be installed in the unzipped folder
after unzipping you might want to move pandoc.exe (for windows) int the directory where the project is located so that it is recognized
So there are two steps in this process for me to get it to work.
1: Install Pandoc
First download the MSI from https://github.com/jgm/pandoc/releases/
If you have trouble installing the MSI by right clicking on it, try creating a batch file with the contents:
cmd /min /C "set __COMPAT_LAYER=RUNASINVOKER && start "" %1"
Then drag and drop the MSI on to this batch file and it will install without asking for any admin privileges.
2:
You'll need to tell the script to find Pandoc if its not running in RStudio already:
if(Sys.getenv("RSTUDIO") != "1"){rmarkdown::find_pandoc(dir = Sys.getenv("pandoc_path"))}
For me Sys.getenv("pandoc_path") = C:/Users/[username]/AppData/Local/Pandoc

Not able to call node from command prompt

I have tried setting node.js in System path but I am still unable to call it from the command prompt in Windows 7
I have to set SET PATH=C:\Program Files\Nodejs;%PATH% every time I want to call it from the command prompt.
set node.js and npm path in environment variables.if its not set as u do for java
Here I'm trying to list the possible reasons, please check each, and if any try to fix it
The path/to/node you are proving is wrong, instead try adding to path as follow
set PATH=%PATH%;c:\Program Files\nodejs
OR for 32bit architecture
set PATH=%PATH%;c:\Program Files(x86)\nodejs
There may be some error so download the latest NODE according to your architecture from here.
If still not working please post more details/error so that we can get idea of what actually is going on.

npm global install does not add packages to PATH on Windows 8.1

When I run npm install -g <package> it installs the packages in my user/AppData/Roaming/npm/npm_modules/ folder. This sub-folder is not in my PATH so if I try to run the package without explicitly calling the entire path the call fails with a '<package>' is not recognized as an internal or external command, operable program or batch file.
What can I do to fix this?
Thanks
I'm using win8.1 and I found that the nodejs installer didn't add the path to global node modules to the system PATH. Just add %AppData%\npm; to the user variable(since %AppData% dir is depending on user) PATH to fix it.
You will need to log out then log back in for the change to your PATH variable to take effect.
SET PATH=%AppData%\npm;%PATH%
You have to run this line SET PATH=pathtonodejs;%PATH% (where pathtonodejs is where you installed nodejs) once the installation for nodejs is complete and it should work.
It turned the problem was a change in behavior of the module I was using.
I'd been following old tutorials for using Express.js. The old tutorials assumed Express would be in my path after installing it globally, but as of Express v4.0 there's a separate Express module you have to install in order to get it in your path

Resources