Closed ciwchris closed 7 years ago
It sounds like it can't find node.exe. Do you not have node.exe on you PATH
environment variable? If you have the latest ASP.NET Web Development Tools installed you shouldn't need node installed at all, but perhaps my logic for adding VS's node.exe to the PATH
is not working properly.
Yes, it is on the path.
c:\d>echo %path%
…;C:\Program Files\nodejs\;…
In fact it's there twice.
I opened up C# Interactive in VS and started replicating the steps in NodeProcess.cs
.
string _installDir = @"C:\Users\username\AppData\Local\Temp\JavaScript Prettier\296021706";
string Packages = "prettier";
var start = new ProcessStartInfo("cmd", $"/c npm install {Packages}")
{
WorkingDirectory = _installDir,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true,
};
string path = start.EnvironmentVariables["PATH"];
var process = Process.GetCurrentProcess();
string ideDir = Path.GetDirectoryName(process.MainModule.FileName);
string parent = Directory.GetParent(ideDir).Parent.FullName;
string rc2Preview1Path = new DirectoryInfo(Path.Combine(parent, @"Web\External")).FullName;
path += ";" + Path.Combine(ideDir, @"Extensions\Microsoft\Web Tools\External");
path += ";" + Path.Combine(ideDir, @"Extensions\Microsoft\Web Tools\External\git");
start.EnvironmentVariables["PATH"] = path;
var proc = Process.Start(start);
proc.WaitForExit();
This installed the node module, but did end with the error:
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\username\AppData\Local\Temp\JavaScript Prettier\296021706\package.json'
Also, I don't have an Extensions
directory, which is created in the Path.Combine
statements.
I haven't tried debugging an extension before. If I clone the project is there a way to step through the extension as it runs?
Same for Visual Studio 2017 RC (26206)
@creage Do you have ASP.NET Web Development workload installed in VS2017?
Apparently - yes, it comes preinstalled/activated for the Web development environment, I believe.
@ciwchris @creage Can you guys try the CSS Sorter extension to see if you get the same error? It uses the same mechanism for installing node modules, but has more telemetry displayed in the Output Window which might be helpful for diagnostics.
Yeah, same results. I didn't see anything in the Output Window. When should I expect to see something? When the extension is installed? After restarting VS? After loading a solution? After opening a CSS file? And in the "Show output from" dropdown should "General" be selected?
Weird. Do you have node.exe and npm.cmd at this location: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Web\External
?
Where Enterprise
is the name of the SKU you've got installed
I do. But I have different order of folders in the "Location of external tools" under the "Project and Solutions/Web Package Management/External Web Tools". And when I restart my VS2017, I got very short message at the bottom, saying that installing Prettier npm module is failed.
I just released version 0.6.16 which writes everything out to the Output Window. Can you try that version and see what the error you get is? And btw, thank you so much for helping troubleshoot this. I'm trying to come up with a generic way to use node modules from VS extensions and need to nail this aspect so it "just works".
That fixed it! The module installed and it runs! Thank you :star:
awesome. Thanks so much :)
@creage if I can get you to try it too just to verify, that would be super helpful.
@madskristensen Thanks a lot - it finally works! But, is there any way to configure it? I believe, VS Code plugin has that option.
Great. Thanks for all the help!!!
Installed product versions
Description
Does not install node module prettier
Steps to recreate
Current behavior
Context menu item is grayed out with the text "(installing npm modules...)"
Expected behavior
I checked the location this plugin attempts to install the prettier node module and the module was not installed there. I restarted VS again to see if it would install, it still did not. I did not see any error messages indicating there was a failure. I manually installed prettier at the expected location. Afterwards the menu item was active. Also, a note here just for awareness but will potentially be a new issue, once the menu item was active it didn't seem to perform any formatting.
Also, I think it would be helpful if the README stated it will install prettier itself, at first I thought it was going to try to use the global version installed by yarn.
I do appreciate the creation of this extension, I was pleasantly surprise to see VS listed as a supported editor.