Scott Hanselman

Visual Studio 2015 - Fixing "Dependencies npm not installed" from fsevents with node on Windows

August 14, '16 Comments [31] Posted in ASP.NET | nodejs
Sponsored By

Maria and I were doing some work together on Thursday and I did a clone of one of her ASP.NET Core repositories and opened it in Visual Studio 2015 Community Edition on my local machine. Some of the JavaScript tool libraries didn't load so I went back into Solution Explorer to see if there was a problem and I saw this weird error that said (or at least, I read it as) "npm not installed."

image

That's weird, since I have npm installed. I dropped out to the command line and ran:

C:\Users\scott>npm --version
3.10.5

I also ran "where" to see where (and how many) npm was installed. Side note: WHERE is super useful and not used as often as it should be by y'all.

C:\Users\scott>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\scott\AppData\Roaming\npm\npm
C:\Users\scott\AppData\Roaming\npm\npm.cmd

This looks OK as two of those npms are shell scripts and not run on Windows. Just to make sure you have the version of npm you want, Felix made a VERY useful npm-windows-upgrade utility that you run like this, ironically with npm.

npm install --global --production npm-windows-upgrade
npm-windows-upgrade

I've used this tool many times with success. It also lets you choose the exact version you want and it's very smart.

However, then I realized that Visual Studio wasn't saying that npm wasn't installed, it was saying a dependency in the npm tree below wasn't installed. That hyphen - is intended to mean something. For the record, I think this is not intuitive and is a poor UX. Perhaps it should say "package(s) not installed" but you get the idea now.

I started manually opening the tree up one item at a time looking for the bad package - while quietly swearing to myself - until I realized that the Solution Explorer tree nodes are searchable.

image

This is UX issue number two, for me. I think the "broken" library should also include the BANG (!) or warning icon over it. Regardless, now I know I can quickly do a string search.

So what's up with the fsevents library?

I can check the Visual Studio Output Window and I see this:

npm WARN install Couldn't install optional dependency: Unsupported
npm WARN EPACKAGEJSON asp.net@0.0.0 No description

I dropped out to the command prompt into to the project's folder and run "npm ls" to see an ASCII tree that effectively is the same tree you see in Visual Studio. Note the screenshot with the ASCII tree below.

The output of "npm ls" is a nice ASCII tree

What's that "UNMET OPTIONAL DEPENDENCY?" for fsevents?

Looks like fsevents is a package that is only used on OSX, so it's an optional dependency that in the case of Windows is "unmet." It's a WARNING, of sorts. Perhaps it's more an "INFO" or perhaps, one could argue, it doesn't need to be shown at all on Windows.

A quick google shows that, well, the entire world is asking the same thing. So much so that it got pretty heated in this GitHub Issue asking a similar question.

Regardless, it seems to me that something inside Visual Studio really doesn't appreciate that warning/info/notOKness and says, "hey it's not installed." The part that is missing is that, well, it doesn't need to be installed, so Visual Studio should relax.

A Fix

Here's where it gets super interesting. Visual Studio (consider it from their point of view) needs to keep things consistent so it tests with, and ships with, a version of npm.

I can check that like this:

C:\>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\npm.cmd" --version
3.3.4

Again, this makes sense. That way when working in a large group we can all be sure we're on the same version of stuff. When you get a new version of the Web Tools for Visual Studio, presumably this version of npm gets updated. This also means that unless you tell Visual Studio otherwise, the npm and node you get when running a build in VS is gonna be different than if you do it outside - if you stick with the default settings.

Fear not. It's easily updated. I went over to Tools | Option in Visual Studio:

Tools | Options | External Web Tools has its own list of node copies, and it doesn't include mine

See the Web\External there? I added my node installation like this and made sure it was at the top.

Tools | Options | External Web Tools has its own list of node copies, and I have ADDED my path now.

Then I right click on npm and Restore Packages and all is right with the world as now I'm using npm 3.10.5 rather than 3.3.4.

There are no npm errors anymore

The Output Window for 3.10.5 shows this different output, which apparently stresses Visual Studio out less than npm 3.3.4. (Actually I think VS is calling an npm library, rather than shelling out and parsing the "npm ls --json" payload, but you get the idea.)

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14

Adding my global npm/node folder fixes this issue for me and I can move on.

The Weird

BUT. In my fix I'm using npm globally - it's in my %PATH%. The change I made affects all Visual Studio projects on my machine, forever.

Maybe I need to be smarter? Maybe Visual Studio is already being smart. Note the second option there in the list? It's pointing to .\node_modules\bin. That's a LOCAL node-modules folder, right? Ah, I can just add specific version of npm to packages.json there if need be on a project by project basis without affecting my entire system OR changing my Visual Studio settings, right?

However, when I run my build, it's ignoring my project's locally installed npm!

PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\npm.CMD" install
npm WARN install Couldn't install optional dependency: Unsupported
npm WARN EPACKAGEJSON asp.net@0.0.0 No description
npm WARN EPACKAGEJSON asp.net@0.0.0 No repository field.
npm WARN EPACKAGEJSON asp.net@0.0.0 No license field.

How can I be sure it's ignoring that relative path? I can temporarily hardcode my local node_modules, like this. Note the PATH *and* the newer output. And it works.

PATH=D:\github\sample-NerdDinner\NerdDinner.Web\node_modules\.bin;node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
"D:\github\sample-NerdDinner\NerdDinner.Web\node_modules\.bin\npm.CMD" install
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN asp.net@0.0.0 No description
npm WARN asp.net@0.0.0 No repository field.
npm WARN asp.net@0.0.0 No license field.

In this screenshot below I have npm 3.10.6 installed in my project, locally, but it's not being used by Visual Studio if the path remains relative.

I am 99% sure that the relative path ".\node_modules\.bin" that's prepended to the PATH above either isn't being used OR is interfering in some way.

Am I misunderstanding how it should work? Perhaps I don't understand npm enough?

image

I'm going to continue to dig into this and I'll update this post when I have an answer. For now, I have a fix given my globally installed npm.

I've also passed my feedback/bug report onto the Visual Studio team in the form of an email with a link to this blog post. I hope this helps someone!


Sponsor: Big thanks to Redgate for sponsoring the feed this week. Could you deploy 1,000 databases?Imagine working in a 70-strong IT team, with 91 applications and 1,000+ databases. Now imagine deployment time. It’s not fiction, it’s fact. Read FlexiGroup's story.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Sunday, 14 August 2016 09:58:23 UTC
I've also had similar pain with the NPM experience in Visual Studio - It's made worse when i tried to add more complexity with things like Typescript configuration.

And worse again that the newer projects seem to work similar to VSCode where they are looking at the directory for the file listing rather than the .proj files. Which is actually great, but it gives me different issues with TFS Bindings and the whole add/commit cycle there.

I'm now at a point where i don't use Visual Studio at all for front-end stuff, as it's just too much of a headache.
Richard
Sunday, 14 August 2016 10:12:35 UTC
That's a great example of why one shouldn't use Visual Studio for this kind of thing. If you want to use npm, use npm cli. Bundling npm with VS is just bad.
John
Sunday, 14 August 2016 10:53:42 UTC
@Scott, thanks for another brilliant piece! While I'm only beginning to touch on node in visual studio in my projects I'm looking forward to this to streamline my development process across the board! 😎

@Richard, could you explain, or point to, your issues with front-end dev in visual studio? I'm wondering what you have found difficult and what types of projects you're building for reference? πŸ€”

@John, I kind of understand your response however I still think this will be a good thing in the long run as the more streamlined our environments are the better off we will be working across platform/environment/device/etc.! Always happy to hear more of your opinion and reasoning! 😏
Jon Humphrey
Sunday, 14 August 2016 11:02:30 UTC
@Jon - ideally i'd want to be able to pull in templates like this : https://github.com/AngularClass/angular2-webpack-starter and use them in Visual Studio. But generally i've found this to be a nightmare and anything more than a basic template for something like Angular w/ typescript is a complete re-work in configuraiton.

In general i'd like if Visual Studio was a little less opinionated in this area - at least for now. It's a forever changing environment so keeping up with it in such an opinionated way will always be very difficult.

It's a real problem for me though as we'd ideally like to use MVC for certain scenarios & SPA + Web API for others. It feels right now like SPA is best developed outside of Visual Studio - which makes it harder for developers who are Visual Studio developers to be motivated to do this. It usually results in ditching the SPA route and back to MVC. I'm aware of the new templates having MVC with Angular2 within, but i've never really been for that personally. I treat my SPA completely seperate from my APIs and treat is as a seperate project.
Richard
Sunday, 14 August 2016 11:18:41 UTC
Personally for me, I write javascript apps (SPA). So I need npm, gulp, typescript build, minification etc etc. In VS you can kind of do it, but it's painful and awkward and half baked. For example, every typescript upgrade was a huuuuuuuuge pain across the team because it's baked in VS, not a npm module (of course, typescript team is to blame here, but that's not the point). Also, while VS Update cadence is super great, for web development it's too slow if web dev is not a core focus.

If you want to know what's wrong with VS for js development - look at Microsoft Visual Studio Code - it's absolutely brilliant! It doesn't try to bundle and do things that it won't be able to keep up and therefore doesn't impose any compatibility problems. You just open a folder where your project sits and you write code.
At this moment VS is maybe more suited to casual/little experienced/classical web page web dev, with all those UIs and bundled it-mostly-works-all-together experience. Case in point - Please don't remove gulp. Don't make Bundler and Minifier the default. - VS team is dumping gulp for their own bundler and minifier. That's just insane and that basically sums up the whole situation.
John
Sunday, 14 August 2016 11:24:37 UTC
Thanks a lot Scott for this interesting blog post. Yesterday, I faced the issue https://github.com/damienbod/Angular2WebpackVisualStudio/issues/3 and I'm happy that you wrote about it. I really enjoy it.
Sunday, 14 August 2016 12:41:01 UTC
Nice article Scott. I'm waiting for the closing/update article on this.

I also agree with John comment previously. I follow ASP.NET Core template project changes since Mads Kristensen explain how to use Task Explorer, npm, gulp and bower in VS. It should have an option for a template to choose e.g. npm+gulp or use bundle json configuration file. Anyway, because of the changes than I chose to always use the Empty template and add all the services and middleware and gulp for the client side development or following the RC2 template one.
Riza Marhaban
Sunday, 14 August 2016 12:57:59 UTC
I also had this issue and I fixed it by configuring the proxy setting of bower.
Jervie
Sunday, 14 August 2016 13:20:57 UTC
@John I'm glad there's someone out there who has also experienced this pain! You're spot on with Visual Studio Code being a shining example. But i still WANT to use Visual Studio for this stuff - it makes adoption of these technologies much simpler if we don't change tools while we do it.

I also love Resharper, but maybe someone just needs to get that done for VSCode..! :D
Richard
Sunday, 14 August 2016 19:03:46 UTC
Moving $(path) to the top to skip the version that comes with vs works for me.
Betty
Monday, 15 August 2016 04:04:52 UTC
Bundling third-party tools with VS is now and has always been a bad idea.

Most developers I've worked with *never* update their tools unless everything becomes unusably broken, and bundling those tools with VS adds an additional layer of never even knowing they need any third-party tools in the first place.

If I took VS away from any of the otherwise-competent developers I work with, they'd not only be incapable of building anything, they'd be incapable of finding the tools they needed to build anything.

I love VS for the most part, but there are a lot of design decisions that seem to be breeding wilfully-ignorant developers.
Anon
Monday, 15 August 2016 09:01:37 UTC
I suggest to use "LONG PATH TOOL" it is very useful for renaming the long file, deleting the error file etc...
webb123
Monday, 15 August 2016 12:10:51 UTC
I am posting this mostly in respectful response to several comments in this thread - i.e. Anon's "willfully ignorant developers" comment. I am a .net web developer and actively learning js client side development. I am enjoying it for the most part but, at the risk of sounding defensive, I am noticing a lot of animosity against .net developers - not just .net in general, but really nasty comments about the.net developer. themselves. To be fair, I have seen this the other way as well, just not at the volume of comments I have observed. What alarms me most about this, is that it is evident not only in forums but in some tutorials I have watched. The tutorials are less aggressive, but still make comments like, "we assume if you call yourself a web developer, you already know "this" (npm, nodejs, gulp...)

now I am hearing it at my job. we have a consultant group training one team and several members of that team have adopted this behavior now.

My concern is not for me personally, but that this is going to adversely affect a team environment and their work, it also creates a barrier of entry for someone like me who is a .netter learning client side development.

My question is, is this as wide-spread as my observations lead me to believe and if so, is there a way to mend the relationships between the 2 camps?
dotNetter
Monday, 15 August 2016 14:03:57 UTC
Thanks for sharing Scott. Was facing this last week and I almost went crazy. +1 for improvement suggestions for Visual Studio related to npm.
Monday, 15 August 2016 14:30:35 UTC
what is "where" and how is it used?
Jeff Lomax
Monday, 15 August 2016 14:32:20 UTC
OH, oh my "where" comment, apparently it's yet another thing that DOESN'T work in PowerShell. Using the command prompt it's fine and obvious.
Jeff Lomax
Monday, 15 August 2016 18:47:50 UTC
It happens to one of my project one day. VERY Annoying. Really look forward the update on this !
Sam Lin
Monday, 15 August 2016 19:01:58 UTC
Jeff - It works, just use "where.exe" as "where" alone is a PowerShell keyword. Or alias something to where.exe. Where is an OLD OLD OLD DOS thing.
Scott Hanselman
Monday, 15 August 2016 19:13:14 UTC
Btw, "until I realized that the Solution Explorer tree nodes are searchable." This one is a saver !
Sam Lin
Monday, 15 August 2016 21:42:01 UTC
@dotNetter I love .NET. I also love Visual Studio. And it is entirely possible to use them and be a great developer. But there are a lot of VS design decisions which seem to be geared toward making devs think less about what they're doing and why.

The idea that everyone should know every tool is ludicrous. But everyone should be able to use the internet to FIND OUT about every tool they need. And, frankly, anyone who isn't interested in learning more about the tools and tech they need to use every day probably shouldn't be writing software. (I'll say the same about any profession, be it doctor, priest, or car mechanic.)
Anon
Tuesday, 16 August 2016 11:27:49 UTC
I'm wondering if this is related to the fact that VS still seems to require gulp to be installed globally - you can specify it as a devDependency in package.json, but even though that causes it to be downloaded, it won't actually run the downloaded version. (Also true on VSTS build agents - unless you install gulp globally on a build agent, gulp doesn't work in ASP.NET Core projects despite being specified as a dev devpendency.)
Wednesday, 17 August 2016 12:50:11 UTC
this solve my problem ,

to cmd
D:\MyprojectDirectory\npm install

and after install, warning depedencies -not installed gone
Friday, 19 August 2016 14:46:26 UTC
This happened to me multiple times. Thanks for the post.
Friday, 26 August 2016 11:14:03 UTC
Hmm, no luck with this solution myself. Updated npm (3.10.3) and pointed visual studio at it with the 'external tools' options and I still get the 'npm - not installed' warning. I get this in the output.

"C:\Program Files\nodejs\npm.CMD" install
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14


Don't seem to be able to get webpack without this warning.
Matt
Tuesday, 30 August 2016 08:27:21 UTC
Like Matt, I've also found that updating npm (3.10.7 in my case) and pointing VS at it produces the different WARN messages (the same as Scott puts in the article), it doesn't get rid of the "not installed" warning.

This output line seem to indicate that I'm picking the new version:

"C:\Program Files (x86)\nodejs\npm.CMD" install

And these warnings are consistent with what Scott says he sees after the update:

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:

npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14

But I still see the "not installed" message in Solution Explorer. So there must be something more to this than updating npm.
Tuesday, 30 August 2016 08:43:26 UTC
Hmm... it turns out that you can make the warnings go away with the following command:

npm set optional=false

This will create a $HOME/.npmrc file if one doesn't already exist, and it adds this line:

optional=false

I'm not sure whether that's a good idea or not, but with this in place, you stop getting any warnings at all when an optional package is unavailable. (I'm guessing the problem is that you also don't get optional packages even when they are available.)

And yet with no warnings at all in the Output window on an npm restore, I still get "not installed" in Solution Explorer.

Again, it's looking like the npm command line isn't the whole problem. At https://github.com/aspnet/Tooling/issues/479 it has been suggested that VS is actually walking the package tree itself. This probably needs to be fixed in the ASP.NET tooling, but it's weird that some people have been able to make this message go away.
Thursday, 01 September 2016 01:26:07 UTC
I agree with Ian Griffiths, I tried Scott's and the five or so things from the comments and I still get the message. That's why I love programming.
Thursday, 01 September 2016 11:50:55 UTC
Visual studio 2013 is a really great service to have and use. Thanks for the tips Scott!
Monaco
Monday, 05 September 2016 18:48:12 UTC
Fixed by removing optional dependency and dependency in Chodikar's pakjage.json.
Jacques
Friday, 09 September 2016 11:51:01 UTC
Life saver! Same exact issue with the same exact optional dependency! :)

Thanks!
Mike
Friday, 09 September 2016 14:33:48 UTC
Confirmed editing the Chokidar module's package.json to remove references to
fsevents
instantly fixed Visual Studio 2015 Update 3's erroneous "Dependencies not installed" message on my Windows environment.

However, this is not a great solution. A permanent fix from npm itself is being released in time, from what I've gathered: it will change the message type to a less severe one (INFO vs. WARN, for instance) so that VS doesn't choke.
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.