npm fsevents_Visual Studio 2015-使用Windows上的节点修复fsevents中的“未安装依赖项npm”

npm fsevents

npm fsevents

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."

Maria和我在星期四一起做一些工作,我克隆了她的一个ASP.NET Core存储库,并在本地计算机上的Visual Studio 2015 Community Edition中将其打开。 一些JavaScript工具库未加载,因此我返回到解决方案资源管理器以查看是否存在问题,并且看到了一个奇怪的错误,该错误说(或至少我读为“未安装npm”)。

image

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

太奇怪了,因为我已经安装了npm。 我退出命令行并运行:

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.

我还运行“哪里”以查看npm的安装位置(和安装数量)。 旁注:WHERE非常有用,使用频率不高。

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.

这看起来不错,因为其中两个npms是shell脚本,不能在Windows上运行。 为了确保您具有所需的npm版本, Felix制作了一个非常有用的npm-windows-upgrade实用程序,您可以像这样使用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.

但是,然后我意识到Visual Studio并不是说未安装npm,而是说未安装下面的npm树中依赖项。 连字符-旨在表示某些意思。 作为记录,我认为这不是直观的,并且是糟糕的用户体验。 也许它应该说“未安装软件包”,但您现在就明白了。

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.

我开始一次手动打开树,以查找不良包装-悄悄地对自己发誓-直到我意识到Solution Explorer树节点是可搜索的

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.

对我来说,这是UX问题第二。 我认为“损坏的”库还应该在其上方包含BANG(!)或警告图标。 无论如何,现在我知道我可以快速进行字符串搜索了。

So what's up with the fsevents library?

那么fsevents库是怎么回事?

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

我可以检查Visual Studio输出窗口,然后看到以下内容:

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.

我退出命令提示符并进入项目的文件夹,然后运行“ npm ls ”来查看ASCII树,该树实际上与您在Visual Studio中看到的树相同。 注意下面带有ASCII树的屏幕截图。

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

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

那是什么?“未知的依赖”? 对于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.

看起来fsevents是仅在OSX上使用的软件包,因此它是一个可选的依赖项,在Windows情况下为“未满足”。 这是一种警告。 也许它更像是一种“信息”,或者也许有人会说,它根本不需要在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.

快速谷歌显示,整个世界都在问同样的事情。 如此之多,以至于在GitHub Issue中提出了类似问题

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.

无论如何,在我看来,Visual Studio中的某些内容实际上并不欣赏警告/信息/ notOKness,而是说:“嘿,它尚未安装。” 缺少的部分是,它不需要安装,因此Visual Studio应该放松。

修复 (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.

这就是超级有趣的地方。 Visual Studio(从他们的角度考虑)需要保持一致,以便它可以与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.

同样,这是有道理的。 这样,当在一个大型小组中工作时,我们都可以确保我们使用的是同一版本的东西。 当获得适用于Visual Studio的Web工具的新版本时,大概是更新了该版本的npm。 这也意味着,除非您另行告知Visual Studio,否则在VS中运行构建时获得的npm和节点将与在外部执行时得到的npm和节点有所不同-如果您坚持使用默认设置。

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

不要害怕。 它很容易更新。 我去了工具| 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.

然后我右键单击npm和Restore Packages,一切都变得正确,因为现在我使用的是npm 3.10.5而不是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.)

3.10.5的“输出”窗口显示了此不同的输出,这显然使Visual Studio承受的压力小于npm 3.3.4。 (实际上,我认为VS调用的是npm库,而不是炮轰并解析“ npm ls --json ”有效负载,但是您明白了。)

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.

添加我的全局npm / node文件夹可以为我解决此问题,我可以继续。

怪异的 (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.

但。 在我的修复程序中,我正在全局使用npm-它在我的%PATH%中。 我所做的更改将永远影响我计算机上的所有Visual Studio项目。

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?

也许我需要变得更聪明? 也许Visual Studio已经很聪明了。 注意列表中的第二个选项吗? 它指向。\ node_modules \ bin 。 那是一个本地节点模块文件夹,对吗? 嗯,如果需要逐个项目地进行,我可以只将特定版本的npm添加到packages.json中,而不影响整个系统或更改Visual Studio设置,对吗?

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

但是,当我运行构建时,它会忽略我的项目在本地安装的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" installnpm 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.

如何确定它忽略了相对路径? 我可以像这样临时对本地的node_modules进行硬编码。 注意PATH和更新的输出。 而且有效。

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" installnpm 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.

在下面的此屏幕截图中,我在本地项目中安装了npm 3.10.6,但是如果路径仍然是相对路径,则Visual Studio不会使用它

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.

我有99%的把握确保上面的PATH之前的相对路径“。\ node_modules \ .bin ”未被使用或以某种方式干扰。

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

我是否误解了它应该如何工作? 也许我对npm不够了解?

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.

我将继续对此进行深入研究,并在有答案的情况下更新此帖子。 就目前而言,我已经安装了全局安装的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!

我还以电子邮件的形式将反馈/错误报告传递给了Visual Studio团队,并带有指向此博客文章的链接。 我希望这可以帮助别人!

翻译自: https://www.hanselman.com/blog/visual-studio-2015-fixing-dependencies-npm-not-installed-from-fsevents-with-node-on-windows

npm fsevents

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值